Skip to content

Storybook: add global preview styles for @wordpress/ui overlays#77451

Merged
ciampo merged 7 commits into
WordPress:trunkfrom
ciampo:chore/storybook-ui-preview-head-global-styles
Apr 21, 2026
Merged

Storybook: add global preview styles for @wordpress/ui overlays#77451
ciampo merged 7 commits into
WordPress:trunkfrom
ciampo:chore/storybook-ui-preview-head-global-styles

Conversation

@ciampo
Copy link
Copy Markdown
Contributor

@ciampo ciampo commented Apr 17, 2026

Related: #76837 (source PR this was extracted from)

What?

Adds global styles in storybook/preview-head.html so the Storybook preview iframe gives portaled @wordpress/ui overlays (dialogs, popovers, etc.) a predictable positioning and stacking context. Records the change under @wordpress/ui Internal changelog as dev-preview documentation.

Why?

#76837 introduced the same rules while migrating modals. Splitting them out lets the Storybook canvas fix land without the rest of that PR, and keeps overlay stories closer to the documented “host” setup for @wordpress/ui.

How?

  • body { position: relative; } — positioning context for portaled layers.
  • #storybook-root { isolation: isolate; } — stacking boundary at the Storybook preview root (SB 10.x convention in this repo).
Implementation notes (optional read)

These rules apply to every story in the monorepo Storybook build (see storybook/main.ts globs), not only packages/ui. That is intentional for a single shared canvas: the same stacking behavior benefits any story using portaled overlays. If we ever need package-specific behavior, a narrower approach (e.g. decorators) would be a follow-up.

Testing Instructions

  1. From the repo root: npm install (if needed), then run npm run storybook:dev (watches packages and starts @wordpress/storybook; see CONTRIBUTING.md for alternatives).

Which stories to prioritize: in the Storybook sidebar, open Design System/Components/Dialog, Design System/Components/AlertDialog, and Design System/Components/Popover. Then optionally Components/Overlays/Modal (or another overlay-heavy story outside @wordpress/ui).

  1. Confirm backdrops and layered content stack and cover the canvas as expected (no “bleed” behind the wrong ancestor).

  2. Accessibility smoke: with Dialog or AlertDialog open, tab through focusable controls and confirm focus rings stay visible and usable (no overlay hiding focus unexpectedly).

CI: the repository Storybook build and Smoke Tests workflow covers Storybook build smoke; stacking and focus still need the manual steps above before merge.

Testing Instructions for Keyboard

Use step 3 above in Storybook only (focus visibility inside open overlays). This PR does not change WordPress editor UI or production keyboard behavior.

Screenshots or screencast

Before After
(empty / default Storybook canvas stacking) (optional) attach a screenshot of a @wordpress/ui Dialog story showing correct backdrop coverage after merge

Use of AI Tools

Pull request description drafted with assistance from Cursor (GPT-based agent). Commits were authored with Cursor for the extraction; changes were reviewed locally before opening the draft PR.

ciampo added 2 commits April 17, 2026 14:24
Inject scoped styles so layered portals (for example Dialog backdrops)
behave consistently when viewing @wordpress/ui stories.

Extracted from #76837.

Made-with: Cursor
@github-actions github-actions Bot added the [Package] UI /packages/ui label Apr 17, 2026
ciampo added 2 commits April 17, 2026 14:34
- Add HTML comments for intentional canvas-wide scope, PR provenance,
  Storybook 10 #storybook-root coupling, and isolation stacking note.
- Clarify CHANGELOG: shared monorepo preview iframe, not npm package assets.

Made-with: Cursor

This comment was marked as resolved.

@ciampo ciampo added the [Type] Enhancement A suggestion for improvement. label Apr 17, 2026
@ciampo ciampo self-assigned this Apr 17, 2026
@ciampo ciampo marked this pull request as ready for review April 17, 2026 13:35
@ciampo ciampo requested a review from a team as a code owner April 17, 2026 13:35
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 17, 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: ciampo <mciampini@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>
Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org>

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

Copy link
Copy Markdown
Member

@mirka mirka left a comment

Choose a reason for hiding this comment

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

Preexisting, but the z-index: 1 on the "Show code" buttons are quite annoying, aren't they 🙁 I wonder if we should just override those, even if a bit hacky. A quick google search seems to show that it's a common pain point.

Comment thread packages/ui/CHANGELOG.md Outdated
Comment thread storybook/preview-head.html Outdated
Comment thread storybook/preview-head.html Outdated
@aduth
Copy link
Copy Markdown
Member

aduth commented Apr 17, 2026

Preexisting, but the z-index: 1 on the "Show code" buttons are quite annoying, aren't they 🙁

I noticed in #77382 that the design of "Show code" buttons has changed in Storybook 10.3. They on longer show above the preview, they show below it. (I don't have a screenshot handy)

@jsnajdr
Copy link
Copy Markdown
Member

jsnajdr commented Apr 17, 2026

They on longer show on top of the preview, they show below it. (I don't have a screenshot handy)

Do you have this in mind?

Screenshot 2026-04-17 at 19 40 47

@aduth
Copy link
Copy Markdown
Member

aduth commented Apr 17, 2026

Yes, that 😄 Thanks @jsnajdr

@github-actions github-actions Bot removed the [Package] UI /packages/ui label Apr 21, 2026
@ciampo ciampo enabled auto-merge (squash) April 21, 2026 09:03
@ciampo ciampo merged commit cb1a260 into WordPress:trunk Apr 21, 2026
38 checks passed
@github-actions github-actions Bot added this to the Gutenberg 23.1 milestone Apr 21, 2026
@alecgeatches alecgeatches added the Storybook Storybook and its stories for components label May 6, 2026
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] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants