Using an anchor (or portal) with ListboxOptions doesn't work with Radix UI’s Dialog
#3715
Replies: 1 comment
|
This is Radix's modal When a Radix When you pass Fix: restore pointer events on the portaled panel: <ListboxOptions anchor="bottom" className="pointer-events-auto">
{/* ... */}
</ListboxOptions>(or This won't cause the dialog to close on click, because Radix decides "outside click" from the React tree position, not the DOM position. Your Listbox is still a React descendant of Side note: Radix's own |
Uh oh!
There was an error while loading. Please reload this page.
What package within Headless UI are you using?
@headlessui/react
What version of that package are you using?
v2.2.2
What browser are you using?
Chrome
Codesandbox
https://codesandbox.io/p/sandbox/jolly-wescoff-ypj3ym
Describe your issue
I'm using Radix UI's
Dialogin my app, and also using Headless UI'sListbox. I ran into a problem where if I apply aportalto theListboxOptions(either directly or viaanchor, which does it automatically), the dropdown stops working, I can't select anything. If I don’t useanchor, everything works fine.Just wondering if anyone else has run into this and found a workaround. I’m considering switching over to Headless UI's
Dialog, but honestly, that’s a pretty big change for me right now.Preview
With anchor
preview.-.with.anchor.mov
Without anchor
preview.-.without.anchor.mov
All reactions