Skip to content

Cookie consent persists to storage but the banner does not hide #452

Closed

Description

@thinkclay

Split out of #438 (closed as not-planned). Sibling of #450, but a distinct fault with a different mechanism — worth tracking separately.

Symptom

Dismissing the cookie banner writes consent but leaves the banner on screen:

  • element.click() on Reject → scf-cookie-consent is written to localStorage → banner stays visible
  • On a fresh load with that key already present, the banner correctly never appears

So load-time gating works; runtime state propagation doesn't.

Evidence that the provider really did update

The stored payload is unmistakably rejectAll's own output:

{"version":"1","updatedAt":"2026-07-30T11:21:10.693Z","selections":{"strictly-necessary":true,"performance":false}}

Only persistSelections writes that shape, and it calls setConsentState(state) before the storage write. So state was set on the same provider instance that renders the visible banner — and the banner still didn't hide.

Candidates already ruled out

  • Context memo deps are complete — packages/ui/src/components/CookieConsent/CookieConsentProvider.tsx lists both consentState and shouldShowBanner in the useMemo dependency array.
  • Not a duplicate provider. The fiber chain reads CookieConsentBanner → CookieConsentProvider → CookieConsentProvider → DatePickerProvider → Provider, which looks like a double mount but isn't: packages/scf-core/provider/cookie-consent/CookieConsentProvider.tsx imports the ui one as CookieConsentProvider as BeyondCookieConsentProvider and renders it inside itself, so both fibers carry the same name by design. The reduce-based compose in provider/index.tsx mounts it once.
  • Single banner — exactly one Reject button inside #root.
  • #S:0 is not a second app — it's React's inert streaming-SSR placeholder (display: none, 0×0). It does contain a copy of the banner markup, which is misleading.

Single provider, correct deps, state set, one banner — and no re-render. That combination is odd enough that I'd want someone to read it with fresh eyes rather than accept my analysis.

Caveat on my own evidence

During part of my session a #S:0 placeholder was present that also contained a Reject button, so an unscoped querySelectorAll('button') could have targeted the wrong copy. The measurement I trust is the one scoped explicitly to document.querySelector('#root') — that wrote consent and left the #root banner visible. The unscoped variants should be re-run.

Why it matters

Consent UI that won't dismiss is a compliance-visible defect: the user's choice is recorded but the interface implies it wasn't, which invites repeat clicks and undermines the audit trail in consent_records.

Note this is reachable via a synthetic click today; with #450 unfixed a real user may not be able to trigger it at all, so fix #450 first — it may change or mask this behaviour.

Related: #438 (closed), #450.

Activity

  1. thinkclay commented on Sep 17, 2026

    @thinkclay
    ContributorAuthor

    Verified on a production export of main + #783 (expo export served by expo serve), with real pointer events (CDP mouse.down/mouse.up at the button's centre, not element.click()), at 375×812 and at 1440×900:

    before click after click
    scf-cookie-consent in localStorage absent written (rejectAll's shape)
    banner container computed opacity 1 0
    screenshot banner shown banner gone
    page errors none none

    So the banner does dismiss. What the original evidence measured was DOM presence: CookieConsentBanner hides by setting opacity: 0 and pointerEvents: 'none' on its container (packages/ui/src/components/CookieConsent/CookieConsentBanner.tsx, the outer View), and never unmounts — so Playwright's isVisible(), querySelector, and "is the Reject button still in #root" all keep answering yes. The caveat in the description about the #S:0 placeholder pointed the same way.

    Closing as not-a-bug for the dismissal. One thing it is worth carrying: an opacity-0 banner keeps three focusable buttons and a heading in the accessibility tree on every page after consent. That is a real a11y defect (and a candidate for the / and /contact accessibility misses in #774, box 4) — the banner should unmount, or at least set aria-hidden / display: none when dismissed. Leaving that note on #774 rather than reopening this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions