Disabled scripts with Opt-in. Don't track visitors unless they specifically give consent. (GDPR compliant) option causes issue with link edit in CKEditor5

Created on 25 April 2024, 7 months ago

Problem/Motivation

Using Disabled scripts with Opt-in. Don't track visitors unless they specifically give consent. (GDPR compliant) option causes issue with link edit in CKEditor5

Steps to reproduce

- Enable EU Cookie Compliance with google_tag module
- Create GTM container from google tag settings page.
- Add below GTM script file in Disabled scripts of EU Cookie Compliance settings page
<your-site-domain>/sites/default/files/google_tag/<gtm_wcms>/google_tag.script.js
- Create content of article type and in body field add a link, then click on the link it will redirect page to link.

Proposed resolution

disabled scripts caches the script into: public://eu_cookie_compliance/eu_cookie_compliance.script.js
Which is loaded always even on admin page from code

/**
   * React to a config object being saved.
   *
   * @param \Drupal\Core\Config\ConfigCrudEvent $event
   *   Config crud event.
   */
  public function configSave(ConfigCrudEvent $event) {

    if (($event->getConfig()->getName() === 'eu_cookie_compliance.settings')) {

      $disabled_javascripts = $event->getConfig()->get('disabled_javascripts');
      if ($disabled_javascripts) {
        $script_snippet = 'window.euCookieComplianceLoadScripts = function(category) {' . $this->getDisabledJsScriptSnippet($disabled_javascripts) . "}";

We should only load/add script where needed, maybe using library.

πŸ› Bug report
Status

Active

Version

1.24

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States imran1217

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

Comments & Activities

Production build 0.71.5 2024