fix(consent): toggle customize panel and clear Clarity cookies on revoke - #1260
Merged
Conversation
- 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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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()inconsent-manager.jsnow checks whether#consent-detailsis already visible. If expanded, it setsdisplay = '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 fromrevokeAllConsent()(the "Withdraw Consent" path). A normal "Reject All" click, or re-opening preferences and rejecting mid-session, sent the Clarityconsentv2signal but never deleted the existing Clarity cookies from the browser.Fix: Added
clearClarityCookies()toclarity-manager.js. It mirrors the domain-iteration logic inclearTrackingCookies()but is scoped to the seven Clarity cookies. It is called fromsyncConsentState()wheneverhasAnalyticsConsent()is false — covering Reject All, mid-session revoke, and the existing Withdraw path.Testing
Playwright tests (injecting patched scripts into live dev site) verified:
_clckcleared on Reject All_clskcleared on Reject AllCLIDcleared on Reject All_clckcleared on mid-session revoke_clskcleared on mid-session revoke_clckcleared on Withdraw_clskcleared on Withdraw