Skip to content

fix(Dialog): focus on open, top dialog only on click outside, role on the panel (3.0) - #357

Merged
lorant-one merged 2 commits into
feat/3-0-breaking-cleanupfrom
fix/dialog-defaults
Nov 1, 2026
Merged

lorant-one merged 2 commits into
feat/3-0-breaking-cleanupfrom
fix/dialog-defaults

Conversation

@lorant-one

Copy link
Copy Markdown
Member

Requested by Lorant · project thread

These fix the Dialog findings from the Graphite migration report, where a real Vite + React app adopted Once UI 2.6 and its e2e suite caught them. 3.0 had already fixed two of them: Escape only closes the innermost overlay, and inert is restored to its previous state. This PR covers what was still open on the 3.0 branch.

Changes

  • Focus enters a Dialog that mounts open. Until the .open class landed a tick later, the overlay was visibility: hidden. focus() does nothing on a hidden element, so focus fell to <body> while the page behind was already inert. For that first frame the overlay is now opacity: 0; pointer-events: none.
  • Click outside: only the innermost dialog answers. Before, a click inside a stacked dialog counted as outside the one beneath it and closed that one too. useOverlay now exposes isInnermost(), the same rule Escape already follows.
  • Toasts work under a dialog. The Toaster region has data-overlay-exempt. The overlay core does not make it inert, and Dialog does not treat clicks on it as outside, so a toast's Undo or Try again can be clicked.
  • One element is the dialog. role="dialog", aria-modal, the accessible name, className and ref all sit on the panel now, as they already do on Drawer. Before, role and name were on the full-screen overlay and className was on the panel. An aria-label now overrides the title as the name, which matters when the title is a node such as a tab bar.
  • A string title renders an h2, not a second h1.
  • MIGRATING.md now has a note about these changes, including one for tests: to click "outside" a dialog, click the role="dialog" element's parent.

Not in this PR (filed separately): the fixed z-index 8/9, the full-screen layout below 1024 px with no size prop, and slot props for body, footer and overlay.

Checks

  • vitest run: 3895/3895 pass. There are new tests for stacked click outside, the exempt Toaster region, role and className on the panel, the aria-label override and the h2 title.
  • tsc --noEmit is clean. Biome reports no new findings in the touched files.

Generated by Claude Code

… the panel (3.0)

From the Graphite migration report (Once UI 2.6 adopted by a real app):

- A Dialog that mounts open never took focus: its overlay was
  visibility: hidden until the open class landed a tick later, and
  focus() on a hidden element does nothing. The overlay is transparent
  and non-interactive for that frame instead.
- Every open Dialog answered clicks outside, so a click in a stacked
  dialog closed the one beneath it. Only the innermost overlay answers
  now, as with Escape (useOverlay exposes isInnermost).
- The Toaster is exempt from the overlay's inert and from click outside
  (data-overlay-exempt), so a toast's Undo works under a dialog.
- role="dialog", aria-modal, the accessible name, className and ref now
  sit on one element, the panel (as on Drawer). aria-label overrides the
  title as its name.
- A string title renders an h2, not a second h1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtvihFgt8bSFzr13Wsn
@vercel

vercel Bot commented Oct 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
core-docs Ignored Ignored Oct 28, 2026 9:44pm UTC

Copy link
Copy Markdown
Member Author

The "Compare" visual check failed on one shot: blocks_quickStart@1280__tile00, 45 px (0.00%). Out of 819 shots, that is the only one that changed. I don't think this PR caused it. The only Dialog on that page has open={false} until a button is clicked, and a closed Dialog renders nothing (the component returns null). The tile is also the top of the page, where BlobFx/ShineFx animate. I'm re-running the visual workflow once to confirm. If the same tile differs again, I'll treat it as real and dig in.


Generated by Claude Code

@lorant-one
lorant-one merged commit e617b6f into feat/3-0-breaking-cleanup Nov 1, 2026
8 checks passed
@lorant-one
lorant-one deleted the fix/dialog-defaults branch November 15, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants