From 73213901d14115c6294b52c2bcf3529baaf85505 Mon Sep 17 00:00:00 2001 From: James Brunton Date: Mon, 23 Feb 2026 20:53:31 +0000 Subject: [PATCH] Fix cookie consent reappearing on desktop builds (#5780) # Description of Changes Fix #5779. Cookie consent persistance doesn't work on desktop (on Mac at least, not sure about Windows) because of permission differences with Tauri. We are allowed to store things in local storage fine, so this switches the cookie consent module to store in local storage for desktop, and leaves it alone for web, where it already worked correctly. --- frontend/src/core/extensions/cookieConsentConfig.ts | 6 ++++++ frontend/src/core/hooks/useCookieConsent.ts | 3 +++ frontend/src/desktop/extensions/cookieConsentConfig.ts | 7 +++++++ 3 files changed, 16 insertions(+) create mode 100644 frontend/src/core/extensions/cookieConsentConfig.ts create mode 100644 frontend/src/desktop/extensions/cookieConsentConfig.ts diff --git a/frontend/src/core/extensions/cookieConsentConfig.ts b/frontend/src/core/extensions/cookieConsentConfig.ts new file mode 100644 index 000000000..5d5b72773 --- /dev/null +++ b/frontend/src/core/extensions/cookieConsentConfig.ts @@ -0,0 +1,6 @@ +/** + * Optional overrides for cookie consent config. + */ +export function getCookieConsentOverrides(): Record { + return {}; +} diff --git a/frontend/src/core/hooks/useCookieConsent.ts b/frontend/src/core/hooks/useCookieConsent.ts index a3a7977c1..40c1a196d 100644 --- a/frontend/src/core/hooks/useCookieConsent.ts +++ b/frontend/src/core/hooks/useCookieConsent.ts @@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next'; import { BASE_PATH } from '@app/constants/app'; import { useAppConfig } from '@app/contexts/AppConfigContext'; import { TOUR_STATE_EVENT, type TourStatePayload } from '@app/constants/events'; +import { getCookieConsentOverrides } from '@app/extensions/cookieConsentConfig'; declare global { interface Window { @@ -112,9 +113,11 @@ export const useCookieConsent = ({ } try { + const overrides = getCookieConsentOverrides(); window.CookieConsent.run({ autoShow: true, hideFromBots: false, + ...overrides, guiOptions: { consentModal: { layout: "bar", diff --git a/frontend/src/desktop/extensions/cookieConsentConfig.ts b/frontend/src/desktop/extensions/cookieConsentConfig.ts new file mode 100644 index 000000000..8a40d7f66 --- /dev/null +++ b/frontend/src/desktop/extensions/cookieConsentConfig.ts @@ -0,0 +1,7 @@ +export function getCookieConsentOverrides(): Record { + return { + cookie: { + useLocalStorage: true, // Cookies don't reliably persist on desktop, but localStorage does + } + }; +}