Allow drupalSettings to be available in StoryBoook

Created on 20 February 2024, 10 months ago

Problem/Motivation

drupalSettings are not available in Storybook because of https://www.drupal.org/project/drupal/issues/2592925 β†’ .

I'm not clear if this is the right module to fix this in.

Steps to reproduce

Access Storybook when functionality relies on drupalSettings being available.

Proposed resolution

https://www.drupal.org/project/drupal/issues/2592925 β†’ prevents drupalSettings getting attached inside of Storybook because the markup is different.

Original

  const settingsElement = document.querySelector(
    'head > script[type="application/json"][data-drupal-selector="drupal-settings-json"], body > script[type="application/json"][data-drupal-selector="drupal-settings-json"]',
  );

Suggested Change

  const settingsElement = document.querySelector(
    'head > script[type="application/json"][data-drupal-selector="drupal-settings-json"], body > script[type="application/json"][data-drupal-selector="drupal-settings-json"], #storybook-root > div > script[type="application/json"][data-drupal-selector="drupal-settings-json"]',
  );

I'm unclear if this opens up any sort of security concerns.

Remaining tasks

Overwriting core's core/drupalSettings library.

✨ Feature request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States joelsteidl

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024