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

Modal: Dropdown interactions trigger a close #813

Open
andy-hook opened this issue Dec 11, 2020 · 4 comments
Open

Modal: Dropdown interactions trigger a close #813

andy-hook opened this issue Dec 11, 2020 · 4 comments
Labels

Comments

@andy-hook
Copy link
Contributor

andy-hook commented Dec 11, 2020

ezgif-2-a912c64fce8f

https://codesandbox.io/s/modal-premature-close-9mhf7?file=/src/App.js

Highly likely to be escapeOutside triggering because the dropdown popover portal is outside the modal dom tree.

@andy-hook andy-hook added the bug label Dec 11, 2020
@andy-hook andy-hook self-assigned this Dec 11, 2020
@bpierre
Copy link
Contributor

bpierre commented Dec 11, 2020

I can’t find a discussion about it, but something we’ve been wanting to implement for a long time is a layering system. A component (or hook) would get used by every component needing one of the properties of a “layer”, which would be handling things related to the focus, the escape key, clicking outside, etc. This layer component would make sure that an escape event only gets propagated to the first one (in the React tree and not the DOM). It would also provide a way to trap the focus, which is missing at the moment.

Edit: probably related to #343

@andy-hook
Copy link
Contributor Author

andy-hook commented Dec 16, 2020

I can’t find a discussion about it, but something we’ve been wanting to implement for a long time is a layering system. A component (or hook) would get used by every component needing one of the properties of a “layer”, which would be handling things related to the focus, the escape key, clicking outside, etc. This layer component would make sure that an escape event only gets propagated to the first one (in the React tree and not the DOM). It would also provide a way to trap the focus, which is missing at the moment.

Edit: probably related to #343

💯 💯 totally agree, leaning on Reacts internal handling of propagation within portals would solve a lot of issues too imo.

@eliobricenov
Copy link
Contributor

hey @andy-hook @bpierre - any steps to reproduce this?

@andy-hook
Copy link
Contributor Author

Hey @eliobricenov, any component using a popover element inside a modal will trigger this behaviour, here's a simplified repro:

https://codesandbox.io/s/modal-premature-close-9mhf7?file=/src/App.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants