Use EU Cookie Compliance new JS Events API

Created on 7 June 2022, about 2 years ago
Updated 17 June 2023, about 1 year ago

Problem/Motivation

Right now, this code is always returning false as when it fires the Eu Cookie Compliance cookie categories are still unset

  Drupal.youtubeCookiesEuCookieCompliance.euCookieComplianceCookiesAccepted = function() {
    return Drupal.eu_cookie_compliance.hasAgreedWithCategory(drupalSettings.youtubeCookies.cookieCategory);
  };

EU Cookie Compliance is using JS hooks to allow other modules to react to its changes, we should use that instead.

Explicitly declaring a dependency on the eu_cookie_compliance library is not enough.

Solution

The method Drupal.eu_cookie_compliance.getAcceptedCategories does read the cookie agreed and returns the list of accepted categories, so it does not depend on the EU cookie compliance behaviours to work.

Something like this might work:

  Drupal.youtubeCookiesEuCookieCompliance.euCookieComplianceCookiesAccepted = function() {
    return $.inArray(drupalSettings.youtubeCookies.cookieCategory, Drupal.eu_cookie_compliance.getAcceptedCategories());
  };
πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ͺπŸ‡ΈSpain idiaz.roncero Madrid

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024