fix(dismissable): register escape handler synchronously when node is available - #3251
Open
kirthi-b wants to merge 1 commit into
Open
fix(dismissable): register escape handler synchronously when node is available#3251kirthi-b wants to merge 1 commit into
kirthi-b wants to merge 1 commit into
Conversation
…available trackDismissableElement deferred its entire setup by one frame when defer: true, so a just-opened dialog was visible and focus-trapped but could not be dismissed with the escape key until the next animation frame. The deferral only exists so the node can be resolved lazily; the interact-outside logic already defers itself internally. Resolve the node eagerly and register handlers synchronously when it is available, keeping the deferred pass only as a fallback for nodes that have not rendered yet. Fixes chakra-ui#3248
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 6f1811b The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Fixes #3248
trackDismissableElementdeferred its whole setup by one frame whendefer: true, so a just-opened dialog was visible and focus trapped but ignored the Escape key until the next animation frame. Under CPU load that window stretches well past one frame.The deferral only exists so the node can be resolved lazily, and the interact-outside logic already defers itself internally via its own
deferoption. This change resolves the node eagerly and registers handlers synchronously when it is available, keeping the deferred pass only as a fallback for nodes that have not rendered yet. The opening click still cannot dismiss the layer, and nested layers keep their stacking order sincelayerStack.addnow runs before any later child registers.Added unit tests covering immediate escape dismissal, the deferred fallback, topmost-only dismissal with nested layers, and cleanup.