Repository navigation
[Bug Fix] Dialog: only dismiss on clicks outside the panel (#570) - #580
Merged
Merged
Conversation
The panel's padding and the gaps between its children report the <dialog> itself as the click target, same as the ::backdrop, so clicking them closed the dialog. Dismiss only when the press both starts and ends outside the panel's rect, which also keeps a text selection dragged outward from closing it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 29, 2026
Collaborator
shadcn audit
|
* [Documentation] Plan: Dialog shadcn parity Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * [Bug Fix] Dialog: vega panel, overlay and text color Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * [Bug Fix] Dialog: vega header, title (h2), description, footer Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * [Feature] Dialog: show_close_button on content and footer Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * [Bug Fix] Dialog: animate open and close Drive tw-animate enter/exit on the panel and its ::backdrop off data-state, set by the controller. Close (X, Cancel, Esc, backdrop) now flips data-state="closed", waits for the dialog's own animations to finish, then calls close(). Reduced motion skips the animation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * [Bug Fix] Dialog: hold exit frame and ignore nested cancel events Keep the closed state's last frame with fill-mode-forwards so the panel and backdrop don't snap back before close(). Only handle `cancel` fired on the dialog itself; a dismissed file picker inside it bubbles one too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * [Bug Fix] Dialog: name the dialog and expose trigger state Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * [Documentation] Dialog: close button options and default size Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * [Bug Fix] Dialog: final review fixes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * [Bug Fix] Dialog: close button interaction states Match the vega ghost icon-sm Button the shadcn close button renders through: transparent border that turns ring-colored on keyboard focus, 1px press offset, select-none, and disabled/aria-expanded states. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * [Documentation] Audit: register Dialog trigger wrapper divergence Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * [Bug Fix] Dialog: address review on plan text and close button tests Plan: drop local paths, use end-4 and motion-reduce:animate-none! to match the code. Tests: render the close button tests without nesting DialogContent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #570
Problem
DialogContentis the native<dialog>itself, withp-6 gap-4.backdropClickdismissed on any click whose target was the<dialog>, but clicks on the panel's own padding and on the gaps between children report the same target as a click on::backdrop. So clicking inside the panel, between two fields, closed the dialog.A related case: selecting text inside the dialog and releasing the mouse outside it also fires
clickon the<dialog>, which closed it mid-selection.Fix
dialog_controller.js: a newbackdropPointerdownrecords whether the press started outside the panel's rect.backdropClickdismisses only when the press both started and ended outside it.dialog_content.rb:data-actionnow also wirespointerdown->ruby-ui--dialog#backdropPointerdown.mcp/data/registry.jsonrebuilt (rake mcp:build).No markup or API change, so
docs/app/views/docs/dialog.rbis unchanged. I kept the panel as the<dialog>instead of moving to a shadcn-style inner wrapper, which would change the DOM that users customize.Testing
cd gem && bundle exec rake: 298 runs, 0 failures. standardrb: no offenses. Added a regression test for thepointerdownaction.main's controller and this branch's:mainTo test manually: open any Dialog on the docs site, click in the padding or between two fields (it should stay open), then click the backdrop (it should close).
Note
#517 (exit animation) also edits
backdropClick. Whichever PR merges second gets a small conflict in that one method.🤖 Generated with Claude Code
Summary by cubic
Brings the dialog to shadcn Base UI + vega parity and fixes clicks on the panel's own padding and gaps dismissing it — those report the
<dialog>as target, same as backdrop clicks, so a press now counts as a backdrop click only when it both starts and ends outside the panel's rect. Dragged text selections that release outside no longer close the dialog either.::backdropoverlay, header, footer, and title (now<h2>); explicitsize:is unchanged and the default width is nowmax-w-mdat sm+.DialogContent(show_close_button:)toggles the corner close button;DialogFooter(show_close_button:)adds a footer Close button.data-state; Esc, backdrop, and the close buttons play the exit animation beforeclose(), withmotion-reducesupport.aria-labelledby/aria-describedby) and setsaria-haspopup/aria-controls/aria-expandedon triggers.Written for commit 33b055e. Summary will update on new commits.