ui icon indicating copy to clipboard operation
ui copied to clipboard

Modal: Dropdown interactions trigger a close

Open andy-hook opened this issue 5 years ago • 4 comments

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 avatar Dec 11 '20 16:12 andy-hook

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 https://github.com/aragon/ui/issues/343

bpierre avatar Dec 11 '20 17:12 bpierre

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.

andy-hook avatar Dec 16 '20 10:12 andy-hook

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

eliobricenov avatar Feb 23 '21 16:02 eliobricenov

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

andy-hook avatar Feb 26 '21 20:02 andy-hook