diff --git a/CHANGELOG.md b/CHANGELOG.md index ccbd5e6a..e502d412 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ ## Unreleased +Compare: + +## 69.13 (2024-01-08) + +Compare: + +- Update cookie message to hide from devices which have previously declined cookies. + ## 69.12 (2023-11-27) Compare: diff --git a/bc/static_src/javascript/components/cookie-message.js b/bc/static_src/javascript/components/cookie-message.js index 2e710eb8..9d8a9f68 100644 --- a/bc/static_src/javascript/components/cookie-message.js +++ b/bc/static_src/javascript/components/cookie-message.js @@ -30,8 +30,12 @@ class CookieWarning { return; } + // If cookie has been declined, do not show the cookie message + if (Cookies.get(this.cookieName) === this.declineValue) { + this.messageContainer.classList.add(this.inactiveClass); + } // If consent is required and not given, show the cookie message - if (!this.hasConsent()) { + else if (!this.hasConsent()) { this.messageContainer.classList.add(this.activeClass); } } diff --git a/bc/static_src/javascript/components/cookie-message.test.js b/bc/static_src/javascript/components/cookie-message.test.js index 1985dbc0..a40591ff 100644 --- a/bc/static_src/javascript/components/cookie-message.test.js +++ b/bc/static_src/javascript/components/cookie-message.test.js @@ -64,4 +64,13 @@ describe('CookieWarning', () => { ); expect(Cookies.get('client-cookie')).toBe('decline cookies'); }); + + it('does not activate if cookie is rejected', () => { + Cookies.set('client-cookie', 'decline cookies'); + + new CookieWarning(document.querySelector(CookieWarning.selector())); + expect(document.querySelector('[data-cookie-message]').className).toBe( + 'cookie inactive', + ); + }); });