Repository navigation
feat(Overlay): allow onBeforeDismiss to return a promise - #1372
Merged
Merged
Conversation
onBeforeDismiss may return a promise, e.g. from MsgBox.yesNo, to ask before an overlay is dismissed. The overlay closes when the promise resolves to anything other than false. While the promise is pending, other attempts to dismiss the overlay, e.g. pressing Escape again, are ignored. If the overlay is closed in another way in the meantime, the result is ignored. onBeforeDismiss is also no longer called again for an overlay that is already closing, e.g. if dismiss is called twice in a row.
mstijak
force-pushed
the
feat/overlay-async-before-dismiss
branch
from
November 24, 2026 19:36
4f831a0 to
cc1f364
Compare
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.
onBeforeDismissmay return a promise, e.g. fromMsgBox.yesNo, to ask before an overlay is dismissed. The overlay closes when the promise resolves to anything other thanfalse. While the promise is pending, other attempts to dismiss the overlay, e.g. pressing Escape again, are ignored. If the overlay is closed in another way in the meantime, the result is ignored.onBeforeDismissis also no longer called again for an overlay that is already closing, e.g. ifdismissis called twice in a row.Follows #1371. Synchronous results and
overlayWillDismisswork as before.Implementation
OverlayComponent.onBeforeDismissreturns a promise ifonBeforeDismissdoes.overlayWillDismissand the rest of the preparation for dismissing (now inbeginDismiss) run after the promise resolves, unless the overlay is unmounting. While a promise is pending, or once dismissing is allowed and the overlay is about to close (dismissed), the method returnsfalse, so other dismiss attempts are ignored; withdismissOnFocusOut, opening aMsgBoxfrom the window would otherwise dismiss it again, and a window with a boundvisiblestays mounted until the next render aftervisibleis set tofalse.dismissof overlays with a boundvisibleand the function returned byopen, usedismissIfAllowed, which waits for a promise and closes the overlay if it allows it.Docs
The
onBeforeDismissrows ofWindowandOverlaymention promises.Tests
New in
Window.browser.spec.tsx:open.In the synchronous tests: "is called once if the window is dismissed twice before it closes".
All but "does nothing when the promise resolves after the window was closed otherwise" fail without the change.