Skip to content

Storybook: Scope Docs theme providers#79496

Merged
ciampo merged 3 commits into
trunkfrom
codex/storybook-docs-theme-root-provider
Jun 26, 2026
Merged

Storybook: Scope Docs theme providers#79496
ciampo merged 3 commits into
trunkfrom
codex/storybook-docs-theme-root-provider

Conversation

@ciampo

@ciampo ciampo commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

What?

Fixes a dev-mode Storybook warning on Docs pages:

ThemeProvider: More than one root provider (isRoot) is mounted on the same document.

Storybook now keeps the Design System theme decorator as a root provider in Canvas mode, but scopes it in Docs mode.

Why?

The Design System theme decorator applied isRoot to every matching story. Canvas pages render one story in the preview iframe, so there was only one root provider. Docs pages also run inside the preview iframe, but their Primary and Stories blocks render multiple stories into that same iframe document rather than separate iframe documents. Each decorated story therefore mounted a competing root provider against the same document.documentElement.

How?

Sets isRoot only when the decorated story is not rendered in Docs mode.

Testing Instructions

  1. Run npm run lint:js -- storybook/decorators/with-design-system-theme.tsx.
  2. Start Storybook in dev mode.
  3. Open Components/Button Docs and confirm the browser console does not show the duplicate root-provider ThemeProvider warning.
  4. Open the individual Components/Button Default story and confirm the warning is still absent.

Testing Instructions for Keyboard

Not applicable; this changes Storybook theme-provider wiring and does not change keyboard interaction.

Screenshots or screencast

Not applicable.

Use of AI Tools

This PR was investigated and drafted with Codex.

@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 7.5 MB

compressed-size-action

@ciampo ciampo self-assigned this Jun 24, 2026
@ciampo ciampo added [Type] Bug An existing feature does not function as intended Storybook Storybook and its stories for components labels Jun 24, 2026
@ciampo ciampo requested a review from a team June 24, 2026 19:54
@ciampo ciampo marked this pull request as ready for review June 24, 2026 19:54
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown

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: ciampo <mciampini@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>

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

Comment thread storybook/decorators/with-design-system-theme.tsx
@ciampo ciampo requested a review from mirka June 25, 2026 14:22
@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown

Flaky tests detected in f60863f.
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/28241948094
📝 Reported issues:


type DesignSystemThemeGlobals = StoryContext[ 'globals' ];

function getDesignSystemThemeSettings( globals: DesignSystemThemeGlobals ) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the refactor, but do I understand correctly that it's unrelated to the fix in question?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we need the tests, it's a good amount of overhead for a noncritical one-liner fix, and it's quite easy to notice any regressions in our daily exposure to the Storybook.

@ciampo ciampo force-pushed the codex/storybook-docs-theme-root-provider branch from 6759c87 to f60863f Compare June 26, 2026 13:42
@ciampo

ciampo commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

@mirka less is more. PR is down to a single line diff :)

@ciampo ciampo enabled auto-merge (squash) June 26, 2026 13:44
@ciampo ciampo merged commit 24339d1 into trunk Jun 26, 2026
41 checks passed
@ciampo ciampo deleted the codex/storybook-docs-theme-root-provider branch June 26, 2026 14:17
@github-actions github-actions Bot added this to the Gutenberg 23.6 milestone Jun 26, 2026
SainathPoojary pushed a commit to SainathPoojary/gutenberg that referenced this pull request Jun 29, 2026
* Storybook: Scope Docs theme providers

* Storybook: Simplify Docs theme provider fix

* Storybook: Remove Docs theme test refactor

---

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
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] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants