How to use Modal with content which is inside a portal?
#6498
jussirantala
started this conversation in
General
Replies: 1 comment 2 replies
-
|
I think this is a duplicate of this issue? Dialog's focus management and work with 3rd party dialogs |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey,
I'm trying to use
ModalOverlayandModalfromreact-aria-componentsand I needComboboxfromheadlessui/reactto be inside the modal.The issue is that when the

Comboboxis opened, the modal size grows because the list is inside modal. To fix that, I used a portal forComboboxand it has higherz-indexthan the modal. Also this portal is later in the DOM tree and it's a sibling, not a children. Now it looks correct and the list "overflows" the modal;But now what happens is that if I click anywhere in the list it closes the modal. Even if I click in an area which is inside the modal. Also even if I add
stopPropagationto click events in the list. It doesn't happen withisDismissable={true}but I want the modal to close if you click outside the modal.How does the
ModalOverlaydetect the "outside" click? It seems it's not just adding a click event to hiddendivwhich covers the screen. Instead it seems it's adding a click event todocument.body, am I right? Does it then check if thetargetof the click event is a children ofModalor what? I don't understand why the modal closes in this case.Beta Was this translation helpful? Give feedback.
All reactions