Skip to content

Storybook: Fix crash when resetting global toolbar selections#76205

Closed
mirka wants to merge 1 commit intotrunkfrom
fix/storybook-reset-crash
Closed

Storybook: Fix crash when resetting global toolbar selections#76205
mirka wants to merge 1 commit intotrunkfrom
fix/storybook-reset-crash

Conversation

@mirka
Copy link
Copy Markdown
Member

@mirka mirka commented Mar 5, 2026

What?

Fixes a crash that occurs when clicking "Reset selection" in the text direction or CSS environment toolbar dropdowns in Storybook.

Why?

When a toolbar global is reset, Storybook sets the value to _reset, which doesn't match any key in the decorator configs. In WithGlobalCSS, destructuring config['_reset'] (undefined) throws immediately. In WithRTL, item['_reset'] is undefined, so spreading it into an array also throws.

This was introduced in #74396 (Storybook v10 + Vite migration).

How?

  • WithGlobalCSS: Falls back to config.none when the globals value doesn't match a known key.
  • WithRTL: Normalizes the direction value to 'ltr' when it's not 'ltr' or 'rtl'.

Testing Instructions

  1. Run Storybook (npm run storybook:dev).
  2. Navigate to any component story (e.g. Button).
  3. In the toolbar, open the "Text direction" or "CSS" dropdown and click "Reset selection".
  4. The story should render without errors.

@mirka mirka self-assigned this Mar 5, 2026
@mirka mirka added [Type] Developer Documentation Documentation for developers Storybook Storybook and its stories for components labels Mar 5, 2026
@mirka mirka requested a review from a team March 5, 2026 16:57
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 5, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: mirka <[email protected]>
Co-authored-by: aduth <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@aduth
Copy link
Copy Markdown
Member

aduth commented Mar 5, 2026

I was confused that Storybook wouldn't be handling this on our behalf, or at least giving us some way to access the "resolved" option value. In my view, "Reset" should be internally represented as the default option.

It looks like this has changed upstream recently (related issue). It might be that we can just upgrade instead? i.e. we're not handling reset behavior, so it wouldn't show a reset option.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 5, 2026

Flaky tests detected in 2ebae5d.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/22728036206
📝 Reported issues:

@mirka
Copy link
Copy Markdown
Member Author

mirka commented Mar 11, 2026

@aduth Good call. Closing in favor of #76403.

@mirka mirka closed this Mar 11, 2026
@mirka mirka deleted the fix/storybook-reset-crash branch March 11, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Storybook Storybook and its stories for components [Type] Developer Documentation Documentation for developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants