Storybook: Fix crash when resetting global toolbar selections#76205
Storybook: Fix crash when resetting global toolbar selections#76205
Conversation
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
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. |
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. InWithGlobalCSS, destructuringconfig['_reset'](undefined) throws immediately. InWithRTL,item['_reset']isundefined, so spreading it into an array also throws.This was introduced in #74396 (Storybook v10 + Vite migration).
How?
WithGlobalCSS: Falls back toconfig.nonewhen 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
npm run storybook:dev).