Skip to content

[bug]: Dialog closes when selecting Combobox item via mouse (portal interaction issue) #10469

@Om-singh-ui

Description

@Om-singh-ui

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

  1. Open a Dialog
  2. Place a Combobox inside it
  3. Open the Combobox
  4. 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

  1. Create a Dialog using shadcn/ui
  2. Add a Combobox (Command + Popover) inside DialogContent
  3. Open the Dialog
  4. Open the Combobox dropdown
  5. 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

  • I've made research efforts and searched the documentation
  • I've searched for existing issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions