Repository navigation
feat(Overlay): call onBeforeDismiss before an overlay is dismissed - #1371
Merged
Merged
Conversation
Overlays such as Window and Dropdown call onBeforeDismiss(instance, component) before they are dismissed, e.g. with Escape, the close button or the function returned by open, and stay open if it returns false. It can also name a controller method. The option was declared in the types, but it was never called. Setting visible to false closes the overlay without calling it.
This was referenced Nov 24, 2026
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.
Overlays such as
WindowandDropdowncallonBeforeDismiss(instance, component)before they are dismissed, e.g. with Escape, the close button or the function returned byopen, and stay open if it returnsfalse. It can also name a controller method. Settingvisibletofalsecloses the overlay without calling it.Related to #1092.
Background
onBeforeDismisswas added toOverlayConfigin the TypeScript conversion of the overlays (5c88bfb), but nothing called it: the name was only used internally, for theonBeforeDismissmethod of the overlay component that runsoverlayWillDismiss. The JavaScript versions and their.d.tsfiles did not have the option, so it never worked.overlayWillDismiss(instance, component)remains as before.Implementation
OverlayComponent.onBeforeDismiss, which runs before every dismissal of a mounted overlay, now invokes the widget'sonBeforeDismisswithinstance.invoke, like the other overlay callbacks, beforeoverlayWillDismiss. The type of the option is nowstring | ((instance, component) => boolean | void).Docs
onBeforeDismissis added to the configuration ofWindowandOverlay.Tests
New in
Window.browser.spec.tsx, which fail without the change: