Module resets existing drupalSettings

Created on 22 March 2023, over 1 year ago

Problem/Motivation

The module removes all existing drupalSettings in sticky_local_tasks_page_attachments_alter(). The hook is using the $attachments by reference, it means that $attachments['#attached']['drupalSettings'] includes all settings that other modules defined before in the order of hooks.

  $settings = [
    'stickyLocalTasks' => [
      'position' => $localStickyPosition,
      'default' => $defaultLocalTasks,
    ],
  ];
  $attachments['#attached']['drupalSettings'] = $settings;

Removing existing drupalSettings could trigger JS errors (undefined properties) on the modules that added drupalSettings before sticky_local_tasks. The JS errors could prevent other JS to run and can break AJAX functionality as well.

Steps to reproduce

Proposed resolution

Do not overwrite $attachments['#attached']['drupalSettings'] but just add our own settings.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇩🇪Germany szeidler Berlin

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

Comments & Activities

Production build 0.71.5 2024