Repository navigation
[6.x] Make Stack and Modal close buttons respect beforeClose - #15685
Merged
Merged
Conversation
The header X, floating X, and StackClose called close() directly, so a beforeClose callback only ran for Esc and backdrop clicks. They now go through runCloseCallback. Programmatic close() is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ts X Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ModalClose called close() directly, skipping the beforeClose callback. It now goes through runCloseCallback, so it still works when the modal isn't dismissible. Also corrects the dismissible prop description to mention Esc. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dismiss() called close() after runCloseCallback had already closed the modal, which emitted update:open twice. 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.
Description of the Problem
A Stack's
beforeClosecallback only ran when closing via Esc or the backdrop. The X button in the header, the floating X, andStackClosecalledclose()directly and skipped it. For example, the Page Editor in a structure tree usesbeforeCloseto warn about unsaved changes, but clicking its X discarded edits without the prompt.The inline publish form (editing a related entry from a relationship field) had the same problem with its own X button, which closed without checking for unsaved changes.
Modals had the same problem with
ModalClose.What this PR Does
The header X, floating X and
StackClosenow go throughrunCloseCallback, the same path Esc and the backdrop use. IfbeforeClosereturns false, the Stack stays open. Callingclose()programmatically (e.g. after saving) and thecloseslot prop still close unconditionally.The inline publish form's X now uses its existing
confirmClose, so it shows the unsaved-changes prompt.ModalClosenow goes throughrunCloseCallbacktoo. It checksbeforeClosebut notdismissible, so a Cancel button in a non-dismissible modal still works. Dismissing a modal (Esc or clicking outside) no longer closes it twice, which emittedupdate:opentwice. Thedismissibleprop description now mentions that it covers Esc as well as clicking outside.Stacks and Modals without a
beforeClosebehave the same as before, since it defaults to() => true.