Skip to content

fix(consent): toggle customize panel and clear Clarity cookies on revoke - #1260

Merged
BenjaminMichaelis merged 1 commit into
mainfrom
bmichaelis-test-cookie-consent
Aug 7, 2026
Merged

fix(consent): toggle customize panel and clear Clarity cookies on revoke#1260
BenjaminMichaelis merged 1 commit into
mainfrom
bmichaelis-test-cookie-consent

Conversation

@BenjaminMichaelis

Copy link
Copy Markdown
Member

Summary

Two consent-system bugs found and fixed via Playwright testing against dev.essentialcsharp.com.

Bug 1 — Customize panel doesn't collapse

Problem: Clicking the "Customize" button a second time always re-showed the details panel. There was no collapse/toggle behavior.

Fix: showCustomizeOptions() in consent-manager.js now checks whether #consent-details is already visible. If expanded, it sets display = 'none' and returns early. Otherwise it opens and pre-fills the checkboxes as before.

Bug 2 — Microsoft Clarity cookies not cleared on Reject/Revoke

Problem: clearTrackingCookies() (which erases _clck, _clsk, CLID, etc.) was only called from revokeAllConsent() (the "Withdraw Consent" path). A normal "Reject All" click, or re-opening preferences and rejecting mid-session, sent the Clarity consentv2 signal but never deleted the existing Clarity cookies from the browser.

Fix: Added clearClarityCookies() to clarity-manager.js. It mirrors the domain-iteration logic in clearTrackingCookies() but is scoped to the seven Clarity cookies. It is called from syncConsentState() whenever hasAnalyticsConsent() is false — covering Reject All, mid-session revoke, and the existing Withdraw path.

Testing

Playwright tests (injecting patched scripts into live dev site) verified:

Scenario Result
Customize opens on 1st click
Customize collapses on 2nd click
Customize re-opens on 3rd click
Analytics checkbox pre-filled on re-open
Clarity cookies seeded before reject
_clck cleared on Reject All
_clsk cleared on Reject All
CLID cleared on Reject All
_clck cleared on mid-session revoke
_clsk cleared on mid-session revoke
_clck cleared on Withdraw
_clsk cleared on Withdraw
Clarity cookies preserved on Accept All

- showCustomizeOptions() now toggles #consent-details visibility:
  clicking Customize a second time collapses the panel instead of
  always showing it
- clarity-manager.js: add clearClarityCookies() that erases _clck,
  _clsk, CLID, ANONCHK, MR, MUID, SM across all candidate domains;
  call it from syncConsentState() whenever analytics consent is denied
  (previously only the Withdraw path cleared these cookies)
@BenjaminMichaelis
BenjaminMichaelis merged commit 9dc9d38 into main Aug 7, 2026
6 checks passed
@BenjaminMichaelis
BenjaminMichaelis deleted the bmichaelis-test-cookie-consent branch August 7, 2026 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant