Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(focus trap): focus trap deactivates on intercepted escape #1133

Conversation

anatolzak
Copy link
Contributor

closes #1132

We should not let the focus trap package deactivate the focus trap on an escape key press because they use capture events which will fire even if an element intercepted the event. Therefore we should never let the focus trap package deactivate based on an escape key press but rather when the dialog or popover unmount which is already implemented in the destroy method of the focus trap action.

Before - I added an escape key interceptor on the dialog content

Screen.Recording.2024-03-29.at.1.14.35.PM.mov

After

Screen.Recording.2024-03-29.at.1.15.16.PM.mov

Copy link

changeset-bot bot commented Mar 29, 2024

🦋 Changeset detected

Latest commit: 7a91b59

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@melt-ui/svelte Patch

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

@anatolzak
Copy link
Contributor Author

@huntabyte I resolved the conflicts :)

@huntabyte huntabyte changed the title fix(focus trap): focus trap deactivates on escape that was intercepted fix(focus trap): focus trap deactivates on intercepted escape Mar 29, 2024
@huntabyte huntabyte merged commit b8deae7 into melt-ui:develop Mar 29, 2024
5 of 6 checks passed
@github-actions github-actions bot mentioned this pull request Mar 29, 2024
@anatolzak anatolzak deleted the fix/focus-trap-deactivates-on-escape-when-intercepted branch March 29, 2024 20:14
lolcabanon pushed a commit to lolcabanon/melt-ui that referenced this pull request Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Focus trap] focus trap deactivates on escape that was intercepted
2 participants