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:
Émile Ré
2026-04-24 12:44:44 +04:00
parent 98dc04b7de
commit 4f4bb72760
2 changed files with 13 additions and 0 deletions

View File

@@ -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 = {

View File

@@ -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");
});