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

improve dialog escape #430

Merged
merged 2 commits into from
Apr 22, 2021
Merged

improve dialog escape #430

merged 2 commits into from
Apr 22, 2021

Conversation

RobinMalfait
Copy link
Member

@RobinMalfait RobinMalfait commented Apr 22, 2021

  • Make sure that Escape only closes the top most Dialog

This is a weird bug honestly, if you have 3 nested Dialogs, press Escape then it will close the top 2 Dialogs. If you have 5 nested Dialogs, press Escape again, the top 2 Dialogs are closed.

The code is now cleaner anyway, because it used to listen to a global window event, instead of scoping it to the Dialog itself.

@vercel
Copy link

vercel bot commented Apr 22, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

headlessui-vue – ./packages/@headlessui-vue

🔍 Inspect: https://vercel.com/tailwindlabs/headlessui-vue/92msU5JaVenAJezAs6XyaAQuTbHg
✅ Preview: https://headlessui-vue-git-improve-dialog-escape-tailwindlabs.vercel.app

headlessui-react – ./packages/@headlessui-react

🔍 Inspect: https://vercel.com/tailwindlabs/headlessui-react/48UpodkVZCo1ZQPNpvG9zPs4kweJ
✅ Preview: https://headlessui-react-git-improve-dialog-escape-tailwindlabs.vercel.app

@RobinMalfait RobinMalfait merged commit 43d5270 into develop Apr 22, 2021
@RobinMalfait RobinMalfait deleted the improve-dialog-escape branch April 22, 2021 14:53
RobinMalfait added a commit that referenced this pull request Apr 26, 2021
* Fixed typos (#350)

* chore: Fix typo in render.ts (#347)

* Better vue link (#353)

* Better vue link

* add better React link

Co-authored-by: Robin Malfait <[email protected]>

* Enable NoScroll feature for the initial useFocusTrap hook (#356)

* enable NoScroll feature for the initial useFocusTrap hook

Once you are using Tab and Shift+Tab it does the scrolling.

Fixes: #345

* update changelog

* Revert "Enable NoScroll feature for the initial useFocusTrap hook (#356)"

This reverts commit 19590b0.

Solution is not 100% correct, so will revert for now!

* Improve search (#385)

* make search case insensitive for the listbox

* make search case insensitive for the menu

* update changelog

* add `disabled` prop to RadioGroup and RadioGroup Option (#401)

* add `disabled` prop to RadioGroup and RadioGroup Option

Also did some general cleanup which in turn fixed an issue where the
RadioGroup is unreachable when a value is used that doesn't exist in the
list of options.

Fixes: #378

* update changelog

* Fix type of `RadioGroupOption` (#400)

Match RadioGroupOption value types to match modelValue allowed types for RadioGroup

* update changelog

* fix typo's

* chore(CI): update main workflow (#395)

* chore(CI): update main workflow

* Update main.yml

* fix dialog event propagation (#422)

* re-export the `screen` utility for quick debugging purposes

* stop event propagation when clicking inside a Dialog

Fixes: #414

* improve dialog escape (#430)

* Make sure that `Escape` only closes the top most Dialog

* update changelog

* add defaultOpen prop to Disclosure component (#447)

* add defaultOpen prop to Disclosure component

* update changelog

Co-authored-by: Shuvro Roy <[email protected]>
Co-authored-by: Alex Nault <[email protected]>
Co-authored-by: Eugene Kopich <[email protected]>
Co-authored-by: Nathan Shoemark <[email protected]>
Co-authored-by: Michaël De Boey <[email protected]>
RobinMalfait added a commit that referenced this pull request Aug 24, 2021
We've "fixed" an issue when we had nested Dialogs ([#430](#430)).
The `escape` would not close the correct Dialog. The issue here was with
the logic to know whether we were the last Dialog or not. The issue was
_not_ how we implemented the `close` functionality.

To make things easier, we moved the global window event to a scoped div
(the Dialog itself). While that fixed the nested Dialog issue, it
introduced this bug where `escape` would not close if you click on a
non-focusable element like a span in the Dialog.

Since that PR we did a bunch of improvements on how the underlying
"stacking" system worked.
This PR reverts to the "global" window event listener so that we can
still catch all of the `escape` keydown events.

Fixes: #524
Fixes: #693
RobinMalfait added a commit that referenced this pull request Aug 24, 2021
* fix broken `escape` key behaviour

We've "fixed" an issue when we had nested Dialogs ([#430](#430)).
The `escape` would not close the correct Dialog. The issue here was with
the logic to know whether we were the last Dialog or not. The issue was
_not_ how we implemented the `close` functionality.

To make things easier, we moved the global window event to a scoped div
(the Dialog itself). While that fixed the nested Dialog issue, it
introduced this bug where `escape` would not close if you click on a
non-focusable element like a span in the Dialog.

Since that PR we did a bunch of improvements on how the underlying
"stacking" system worked.
This PR reverts to the "global" window event listener so that we can
still catch all of the `escape` keydown events.

Fixes: #524
Fixes: #693

* update changelog
obianachebe pushed a commit to obianachebe/headlessui-react that referenced this pull request Dec 21, 2021
* fix broken `escape` key behaviour

We've "fixed" an issue when we had nested Dialogs ([#430](tailwindlabs/headlessui#430)).
The `escape` would not close the correct Dialog. The issue here was with
the logic to know whether we were the last Dialog or not. The issue was
_not_ how we implemented the `close` functionality.

To make things easier, we moved the global window event to a scoped div
(the Dialog itself). While that fixed the nested Dialog issue, it
introduced this bug where `escape` would not close if you click on a
non-focusable element like a span in the Dialog.

Since that PR we did a bunch of improvements on how the underlying
"stacking" system worked.
This PR reverts to the "global" window event listener so that we can
still catch all of the `escape` keydown events.

Fixes: #524
Fixes: #693

* update changelog
googoogaga0xbb added a commit to googoogaga0xbb/ui-headless that referenced this pull request Nov 29, 2023
* fix broken `escape` key behaviour

We've "fixed" an issue when we had nested Dialogs ([#430](tailwindlabs/headlessui#430)).
The `escape` would not close the correct Dialog. The issue here was with
the logic to know whether we were the last Dialog or not. The issue was
_not_ how we implemented the `close` functionality.

To make things easier, we moved the global window event to a scoped div
(the Dialog itself). While that fixed the nested Dialog issue, it
introduced this bug where `escape` would not close if you click on a
non-focusable element like a span in the Dialog.

Since that PR we did a bunch of improvements on how the underlying
"stacking" system worked.
This PR reverts to the "global" window event listener so that we can
still catch all of the `escape` keydown events.

Fixes: #524
Fixes: #693

* update changelog
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.

1 participant