From 16504814a884746795614af8096469119f890dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Fri, 8 May 2026 11:28:58 +0400 Subject: [PATCH] Fix opt-out button opening panel instead of rejecting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In OPT_OUT mode the button_opt_out text was mapped to button_customize, which opens the preference panel. Map it to button_reject_all instead so the button performs a one-click reject for all OPT_OUT regulations. Signed-off-by: Émile Ré --- pkg/cookiebanner/service.go | 4 ++-- pkg/cookiebanner/service_test.go | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/cookiebanner/service.go b/pkg/cookiebanner/service.go index 1ce6351bb..ca8e22de3 100644 --- a/pkg/cookiebanner/service.go +++ b/pkg/cookiebanner/service.go @@ -1616,8 +1616,8 @@ func remapTextsForConsentMode(texts map[string]string, consentMode string, regul remapTextKey(texts, "banner_title_opt_out", "banner_title") remapTextKey(texts, "banner_description_opt_out", "banner_description") remapTextKey(texts, "button_acknowledge", "button_accept_all") - remapTextKey(texts, "button_opt_out", "button_customize") - texts["button_reject_all"] = "" + remapTextKey(texts, "button_opt_out", "button_reject_all") + texts["button_customize"] = "" case regulation == RegulationNone: remapTextKey(texts, "banner_title_notice", "banner_title") diff --git a/pkg/cookiebanner/service_test.go b/pkg/cookiebanner/service_test.go index c59f57e21..8bc03d3d4 100644 --- a/pkg/cookiebanner/service_test.go +++ b/pkg/cookiebanner/service_test.go @@ -308,13 +308,15 @@ func TestRemapTextsForConsentMode(t *testing.T) { assert.Empty(t, texts["button_customize"]) }) - t.Run("opt out mode clears reject", func(t *testing.T) { + t.Run("opt out mode maps opt out to reject and clears customize", func(t *testing.T) { t.Parallel() texts := baseTexts() + texts["button_opt_out"] = "Do Not Sell" remapTextsForConsentMode(texts, ConsentModeOptOut, RegulationCCPA) - assert.Empty(t, texts["button_reject_all"]) + assert.Equal(t, "Do Not Sell", texts["button_reject_all"]) + assert.Empty(t, texts["button_customize"]) }) }