diff --git a/CHANGELOG.md b/CHANGELOG.md index c0597f3920..1746f468b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ * Fix track click link tracking ([PR #2265](https://github.com/alphagov/govuk_publishing_components/pull/2265)) * Add language tag for Welsh link in public layout template ([PR #2258](https://github.com/alphagov/govuk_publishing_components/pull/2258)) +* Revert "Fix cookie banner issue (IE10)" ([PR #2267](https://github.com/alphagov/govuk_publishing_components/pull/2267)) # 25.3.0 diff --git a/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js b/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js index 0e7899560f..5c289bfb31 100644 --- a/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +++ b/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js @@ -27,11 +27,13 @@ window.GOVUK.Modules = window.GOVUK.Modules || {}; this.$acceptCookiesButton = this.$module.querySelector('button[data-accept-cookies]') if (this.$acceptCookiesButton) { + this.$acceptCookiesButton.style.display = 'block' this.$acceptCookiesButton.addEventListener('click', this.$module.setCookieConsent) } this.$rejectCookiesButton = this.$module.querySelector('button[data-reject-cookies]') if (this.$rejectCookiesButton) { + this.$rejectCookiesButton.style.display = 'block' this.$rejectCookiesButton.addEventListener('click', this.$module.rejectCookieConsent) } @@ -44,7 +46,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {}; var shouldHaveCookieMessage = (this.$module && window.GOVUK.cookie('cookies_preferences_set') !== 'true') if (shouldHaveCookieMessage) { - this.$module.removeAttribute('hidden') + this.$module.style.display = 'block' // Set the default consent cookie if it isn't already present if (!window.GOVUK.cookie('cookies_policy')) { @@ -53,16 +55,17 @@ window.GOVUK.Modules = window.GOVUK.Modules || {}; window.GOVUK.deleteUnconsentedCookies() } else { - this.$module.setAttribute('hidden', '') + this.$module.style.display = 'none' } } else { - this.$module.setAttribute('hidden', '') + this.$module.style.display = 'none' } } CookieBanner.prototype.hideCookieMessage = function (event) { if (this.$module) { - this.$module.setAttribute('hidden', '') + this.$module.hidden = true + this.$module.style.display = 'none' window.GOVUK.cookie('cookies_preferences_set', 'true', { days: 365 }) } @@ -98,8 +101,9 @@ window.GOVUK.Modules = window.GOVUK.Modules || {}; CookieBanner.prototype.showConfirmationMessage = function () { this.$cookieBannerMainContent = document.querySelector('.js-banner-wrapper') - this.$cookieBannerMainContent.setAttribute('hidden', '') - this.$module.cookieBannerConfirmationMessage.removeAttribute('hidden') + this.$cookieBannerMainContent.hidden = true + this.$module.cookieBannerConfirmationMessage.style.display = 'block' + this.$module.cookieBannerConfirmationMessage.hidden = false } CookieBanner.prototype.isInCookiesPage = function () { diff --git a/app/assets/stylesheets/component_guide/application.scss b/app/assets/stylesheets/component_guide/application.scss index 9dc7ce6d90..440e1d1149 100644 --- a/app/assets/stylesheets/component_guide/application.scss +++ b/app/assets/stylesheets/component_guide/application.scss @@ -499,9 +499,3 @@ $code-delete-bg: #fadddd; top: 0; background: govuk-colour("white"); } - -.gem-c-cookie-banner[hidden] { - .js-enabled & { - display: block; - } -} diff --git a/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss b/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss index 379afa31f0..69efc999e6 100644 --- a/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +++ b/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss @@ -1,10 +1,9 @@ @import "govuk/components/cookie-banner/cookie-banner"; $govuk-cookie-banner-background: govuk-colour("light-grey", "grey-4"); -.gem-c-cookie-banner[hidden] { - display: block; // shown with JS, always on for non-JS - .js-enabled & { - display: none; +.js-enabled { + .gem-c-cookie-banner { + display: none; // shown with JS, always on for non-JS } } @@ -15,13 +14,9 @@ $govuk-cookie-banner-background: govuk-colour("light-grey", "grey-4"); // can't be used without js so implement there .gem-c-cookie-banner .gem-c-button { display: none; - - .js-enabled & { - display: block; - } } -.gem-c-cookie-banner__confirmation[hidden] { +.gem-c-cookie-banner__confirmation { display: none; position: relative; padding: govuk-spacing(1); diff --git a/app/views/govuk_publishing_components/components/_cookie_banner.html.erb b/app/views/govuk_publishing_components/components/_cookie_banner.html.erb index b942502b4b..df970e080a 100644 --- a/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +++ b/app/views/govuk_publishing_components/components/_cookie_banner.html.erb @@ -29,7 +29,7 @@ css_classes = %w(gem-c-cookie-banner govuk-clearfix) css_classes << "gem-c-cookie-banner--services" if services_cookies %> -