Problem/Motivation
The two Hero/Heroslider stories render nothing. The story supplies its slides as render arrays whose key is written "'#markup'", and Drupal rejects that. Watchdog records "'#markup'" is an invalid render array key at vartheme_bs5_rightup:heroslider line 117.
With PHP assertions on (DDEV) the same fault surfaces earlier as AssertionError: Bubbling failed in core/lib/Drupal/Core/Render/Renderer.php. With assertions off (zend.assertions=-1, as on Upsun) the story returns HTTP 200 with an empty wrapper, so it looks fine to a status-code check.
The key representation cannot be fixed. The text of a JSON key in a *.stories.json file is consumed verbatim by two different things that want opposite things:
@storybook/preset-server-webpackturns the JSON into a JavaScript module, where"#markup"emits a bare#markup:key, a syntax error because#begins a private class field. That breaks the entire Storybook preview build, not just this story.- Drupal's render endpoint parses the same file as JSON, where
"'#markup'"is the literal key'#markup', quotes included, which is not a valid render array key.
So "#markup" breaks Storybook and "'#markup'" breaks Drupal. Both were tried.
Steps to reproduce
- Build a Varbase 11 site with The Rightup site template and Vartheme BS5 Rightup 1.0.x (verified at commit 566661c).
- Run Storybook:
ddev yarn storybook:dev. - Open Hero / Heroslider / Hero Slider - Three Slides. Nothing renders.
ddev drush watchdog:show --severity=Errorshows the invalid render array key.
Proposed resolution
Stop passing a render array through story args. The slides become plain HTML strings in items, and heroslider.stories.twig converts each to raw markup before the include, using the idiom the same story already uses for its empty prop:
{% set raw_items = [] %} {% for item in items %} {% set slide %}{{ item|raw }}{% endset %} {% set raw_items = raw_items|merge([slide]) %} {% endfor %} {% set items = raw_items %}
A JSON array of strings is valid JavaScript and valid input for Drupal, so both consumers are satisfied.
Verified: "Hero Slider - Three Slides" renders 3 carousel items and 3 slide titles, "Hero Slider - One Slide" renders 1, "Empty Hero Slider" renders its empty state, and the Storybook preview build compiles and serves.
A merge request will follow.
Remaining tasks
- ✅ File an issue
- ❌ Addition/Change/Update/Fix
- ❌ Testing to ensure no regression
- ➖ Automated unit/functional testing coverage
- ➖ Developer Documentation support
- ➖ User Guide Documentation support
- ➖ UX/UI designer responsibilities
- ➖ Accessibility and Readability
- ❌ Reviewed by a human
- ❌ Code review by maintainers
- ❌ Full testing and approval
- ❌ Credit contributors
- ❌ Review with the product owner
- ❌ Update Release Notes
- ❌ Release
User interface changes
- N/A
API changes
- N/A
Data model changes
- N/A
Release notes snippet
- Hero Slider stories render again in Storybook. Slides are passed as HTML strings instead of render arrays.
Issue fork vartheme_bs5_rightup-3627180
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
rajab natshahComment #5
rajab natshah