Clear GPC badge when user overrides consent via preference panel
When the user explicitly changes consent (accept all, reject all, or customize), clear the gpcApplied flag and remove the gpc-label attribute from the settings button so the "Opt-Out Preference Signal Honored" badge no longer displays. Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -154,6 +154,7 @@ export class CookieBannerClient {
|
||||
}
|
||||
|
||||
if (!this.consent && this.gpcDetected) {
|
||||
console.log("GPC")
|
||||
this.gpc();
|
||||
this._gpcApplied = true;
|
||||
}
|
||||
@@ -233,6 +234,10 @@ export class CookieBannerClient {
|
||||
action: ConsentAction,
|
||||
consentData: Record<string, boolean>,
|
||||
): void {
|
||||
if (action !== "GPC") {
|
||||
this._gpcApplied = false;
|
||||
}
|
||||
|
||||
const cfg = this.config;
|
||||
|
||||
this.consent = {
|
||||
|
||||
@@ -141,6 +141,14 @@ export class ProboThemedBanner extends HTMLElement {
|
||||
}
|
||||
});
|
||||
|
||||
root.addEventListener("probo-consent", (e: Event) => {
|
||||
const { action } = (e as CustomEvent).detail;
|
||||
if (action !== "GPC") {
|
||||
const settingsBtn = this.shadow.querySelector("probo-settings-button");
|
||||
settingsBtn?.removeAttribute("gpc-label");
|
||||
}
|
||||
});
|
||||
|
||||
this.shadow.querySelector("[data-action=back]")?.addEventListener("click", () => {
|
||||
root.setState(root.client.hasConsent ? "hidden" : "banner");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user