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

Ignore Escape when event got prevented in Dialog component #1424

Merged
merged 2 commits into from
May 9, 2022

Conversation

RobinMalfait
Copy link
Collaborator

@RobinMalfait RobinMalfait commented May 9, 2022

Some external libraries only use event.preventDefault() and not event.stopPropagation(). This means that the Dialog can still receive an Escape keydown event which closes the Dialog.

We can also think about the Escape behaviour inside the modal as the "default behaviour" once the Dialog is open. Therefore, we can also check the event.defaultPrevented and ignore this event when this is the case.

Some external libraries only use `event.preventDefault()` and not
`event.stopPropagation()`. This means that the Dialog can still receive
an `Escape` keydown event which closes the Dialog.

We can also think about the `Escape` behaviour inside the modal as the
"default behaviour" once the Dialog is open. Therefore, we can also
check the `event.defaultPrevented` and ignore this event when this is
the case.
@vercel
Copy link

vercel bot commented May 9, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
headlessui-react ✅ Ready (Inspect) Visit Preview May 9, 2022 at 1:07PM (UTC)
headlessui-vue ✅ Ready (Inspect) Visit Preview May 9, 2022 at 1:07PM (UTC)

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.

None yet

1 participant