From f29a2f05cce399dd2d5c574f90fd7dc05526033b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Fri, 24 Apr 2026 13:05:02 +0400 Subject: [PATCH] Fix gpc applied from cookie / api consent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Émile Ré --- packages/cookie-banner/src/client.ts | 3 ++- packages/cookie-banner/src/components/settings-button.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/cookie-banner/src/client.ts b/packages/cookie-banner/src/client.ts index 85d253cf2..d8012e4fe 100644 --- a/packages/cookie-banner/src/client.ts +++ b/packages/cookie-banner/src/client.ts @@ -119,6 +119,7 @@ export class CookieBannerClient { consent_data: cookie.data, created_at: "", }; + this._gpcApplied = cookie.action === "GPC"; this.activate(cookie.data); void flush(this.bannerId); return; @@ -139,6 +140,7 @@ export class CookieBannerClient { if (apiConsent && apiConsent.version === config.version) { this.consent = apiConsent; + this._gpcApplied = apiConsent.action === "GPC"; setConsentCookie( { v: apiConsent.version, @@ -154,7 +156,6 @@ export class CookieBannerClient { } if (!this.consent && this.gpcDetected) { - console.log("GPC") this.gpc(); this._gpcApplied = true; } diff --git a/packages/cookie-banner/src/components/settings-button.ts b/packages/cookie-banner/src/components/settings-button.ts index e28600953..d9e9a8e77 100644 --- a/packages/cookie-banner/src/components/settings-button.ts +++ b/packages/cookie-banner/src/components/settings-button.ts @@ -97,7 +97,7 @@ export class ProboSettingsButton extends HTMLElement { this.root = this.findRoot(); if (this.root) { - if (this.root.reopenWidget === "custom") { + if (this.root.reopenWidget === "custom" && !this.root.gpcApplied) { return; } @@ -142,7 +142,7 @@ export class ProboSettingsButton extends HTMLElement { private onReopenWidgetChange = (e: Event): void => { const { value } = (e as CustomEvent).detail; - if (value === "custom") { + if (value === "custom" && !this.root?.gpcApplied) { this.hidden = true; this.root?.removeEventListener("probo-state", this.onStateChange); this.root?.removeEventListener("probo-reopen-widget", this.onReopenWidgetChange);