Describe the bug
When using a Combobox (Command/Popover) inside a Dialog, selecting an item via mouse click causes the Dialog to close unexpectedly.
However, selecting the same item using the keyboard (Enter key) does NOT close the Dialog.
Expected behavior
- Selecting an item inside the Combobox should NOT close the Dialog
- Dialog should only close on actual outside interaction
Current behavior
- Mouse click on Combobox item → Dialog closes
- Keyboard selection (Enter) → Dialog stays open
Reproduction
- Open a Dialog
- Place a Combobox inside it
- Open the Combobox
- Click an item using the mouse
Dialog closes unexpectedly
Root cause (analysis)
This appears to be caused by how Radix handles portals.
The Combobox (Popover/Command) is rendered in a portal, so when clicking an item:
- The event is treated as an "outside interaction"
- Dialog's
onInteractOutside is triggered
- Dialog closes
Keyboard selection does not trigger a pointer event, so it works correctly.
Current workaround
<DialogContent
onInteractOutside={(e) => {
e.preventDefault()
}}
>
Affected component/components
Dialog, Combobox (Command), Popover
How to reproduce
- Create a Dialog using shadcn/ui
- Add a Combobox (Command + Popover) inside DialogContent
- Open the Dialog
- Open the Combobox dropdown
- Click an item using the mouse
Dialog closes unexpectedly
Codesandbox/StackBlitz link
Not provided yet can add if needed.
Logs
No console errors observed.
System Info
- OS: Windows
- Browser: Chrome
- shadcn/ui: latest
- Framework: Next.js / React
Before submitting
Describe the bug
When using a Combobox (Command/Popover) inside a Dialog, selecting an item via mouse click causes the Dialog to close unexpectedly.
However, selecting the same item using the keyboard (Enter key) does NOT close the Dialog.
Expected behavior
Current behavior
Reproduction
Dialog closes unexpectedly
Root cause (analysis)
This appears to be caused by how Radix handles portals.
The Combobox (Popover/Command) is rendered in a portal, so when clicking an item:
onInteractOutsideis triggeredKeyboard selection does not trigger a pointer event, so it works correctly.
Current workaround
Affected component/components
Dialog, Combobox (Command), Popover
How to reproduce
Dialog closes unexpectedly
Codesandbox/StackBlitz link
Not provided yet can add if needed.
Logs
System Info
Before submitting