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
ModalOverlay
andModal
fromreact-aria-components
and I needCombobox
fromheadlessui/react
to be inside the modal.The issue is that when the

Combobox
is opened, the modal size grows because the list is inside modal. To fix that, I used a portal forCombobox
and it has higherz-index
than 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
stopPropagation
to 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
ModalOverlay
detect the "outside" click? It seems it's not just adding a click event to hiddendiv
which covers the screen. Instead it seems it's adding a click event todocument.body
, am I right? Does it then check if thetarget
of the click event is a children ofModal
or what? I don't understand why the modal closes in this case.Beta Was this translation helpful? Give feedback.
All reactions