shadcn-multi-select-component icon indicating copy to clipboard operation
shadcn-multi-select-component copied to clipboard

Doesn't work inside a Dialog component

Open jackiepapers opened this issue 1 year ago • 9 comments

Clicking first item has no effect, clicking second item closes dialog. Clicking close button also closes dialog.

jackiepapers avatar Oct 05 '24 22:10 jackiepapers

This component uses a Popover, so when wrapping it in a Dialog, you need to set modalPopover={true} as per https://github.com/radix-ui/primitives/issues/2121#issuecomment-2227348602

<MultiSelect
    modalPopover={true}
    options={...}
    onValueChange={...}
/>

ryanschiang avatar Oct 08 '24 03:10 ryanschiang

This component uses a Popover, so when wrapping it in a Dialog, you need to set modalPopover={true} as per radix-ui/primitives#2121 (comment)

<MultiSelect
    modalPopover={true}
    options={...}
    onValueChange={...}
/>

thanks, this solves the issue, but the search and scrollbar of multi-select still not working when inside dialog

wflkaaa avatar Mar 06 '25 04:03 wflkaaa

This component uses a Popover, so when wrapping it in a Dialog, you need to set modalPopover={true} as per radix-ui/primitives#2121 (comment)

<MultiSelect
    modalPopover={true}
    options={...}
    onValueChange={...}
/>

thanks, this solves the issue, but the search and scrollbar of multi-select still not working when inside dialog

Yes, scrolling and searching now does not work. Is there a work around for this?

zaidrashid avatar Mar 12 '25 12:03 zaidrashid

If use modalPopover={true}, it will throw aria-hidden error Finally i fixed the problem with pointerEvents First: modalPopover={false}

Image

Second: add style={{ pointerEvents: "auto" }} in popover content

Image

Image

Preview:

Image

Remove the Portal will always fixed, same problem as search. But event can't fix it

godcong avatar Mar 13 '25 06:03 godcong

To fix the search I did modal={false} on <Sheet /> or <Dialog/> and also modalPopover={false} on MultiSelect Component

<Dialog
  modal={false}
>
   ...
    <MultiSelect
        modalPopover={false}
        options={...}
        onValueChange={...}
    />
  ...
</Dialog>

m5khan avatar Mar 17 '25 11:03 m5khan

Thanks @m5khan !! this approach worked just fine!

paulotolentino avatar Apr 11 '25 02:04 paulotolentino

I resolved the scroll with the following code:

  <PopoverContent
    ...
    onWheel={(e) => {
      e.stopPropagation();
    }}
    onTouchMove={(e) => {
      e.stopPropagation();
    }}
  >

https://github.com/radix-ui/primitives/issues/1159

ws-t-jer avatar May 13 '25 19:05 ws-t-jer

for the search issue use PopoverContentDialog instead of PopoverContent inside the component

BaraJabali avatar May 21 '25 12:05 BaraJabali

try below approach, it's worked for me https://github.com/shadcn-ui/ui/issues/1511#issuecomment-1784645453

arrizkyhp avatar May 26 '25 07:05 arrizkyhp