Repository navigation
Mouse hover/click doesn't work on Headless UI ComboboxOptions with anchor inside Dialog #4033
DescriptionI'm seeing an interoperability issue between When a Headless UI Combobox is rendered inside a Radix Dialog, the dropdown opens correctly and keyboard interaction works, but mouse hover and click do not work on the options. Environment
Expected behavior
Actual behavior
ReproductionThe issue only occurs when using: <ComboboxOptions anchor="bottom start">inside: <Dialog.Content>If I remove the <ComboboxOptions>everything works correctly. The same Combobox also works correctly outside of Radix Dialog. Notes
Is this a known limitation or an interoperability issue with anchored positioning? |
Replies: 2 comments 2 replies
|
Generally speaking, trying to coordinate behavior with other libraries' popover behavior is not something we can reliably do. There are too many other implementations with their own quirks, and at the end of the day many of these behaviors are essentially global DOM state. Moved this to a discussion in case others who have experience with Headless UI want to propose workarounds. |
|
Chiming in with a workaround since this is really a Radix modal-Dialog interaction, not something Headless UI can fix from its side. Why it happens With
Keyboard nav still works because it's focus/key-driven, not pointer-gated, which matches your exact symptom set. Workaround <ComboboxOptions anchor="bottom start" className="pointer-events-auto">
{/* ... */}
</ComboboxOptions>(or You don't need an |
Chiming in with a workaround since this is really a Radix modal-Dialog interaction, not something Headless UI can fix from its side.
Why it happens
With
modal={true}, Radix's dismissable layer setspointer-events: noneon<body>and only re-enablesautoon theDialog.Contentsubtree (that's how it blocks the rest of the page). Headless UI'sanchorprop portalsComboboxOptionstodocument.bodyso it can float against the input, which puts the options outsideDialog.Contentin the DOM, so they inheritpointer-events: none:anchor-> options render insideDialog.Content->pointer-events: auto-> mouse worksanchor-> portaled tobody->pointer-events: none-> mouse deadKeyb…