ui icon indicating copy to clipboard operation
ui copied to clipboard

[bug]: ComboBox item scroll (Mouse wheel) is not working inside Dialoge Box

Open manishoctal opened this issue 1 year ago • 7 comments

Describe the bug

ComboBox item scroll (Mouse wheel) is not working inside Dialoge Box

https://github.com/user-attachments/assets/da1a3ce8-a543-4de5-a9b4-4eb19ac36246

Affected component/components

Combobox, Dialog

How to reproduce

  1. Click on Filter
  2. Click on Combobox
  3. Scroll inside the combobox for more items, mouse scroll wheel not working.

https://github.com/user-attachments/assets/38e3781a-b5e8-4979-9c94-56d1820e9911

Codesandbox/StackBlitz link

No response

Logs

No response

System Info

Chrom, Windows 11

Before submitting

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

manishoctal avatar Sep 06 '24 10:09 manishoctal

Description

Upon investigation, the combo box and Dialog are rendered as sibling elements under the body tag due to the use of React’s Portal. While React maintains the parent-child relationship, the actual HTML structure differs. The combo box’s container is currently set to body, causing scrolling issues within the Dialog.

To resolve this, the combo box’s container is now configurable, allowing it to be rendered within the Dialog instead of directly under the body, ensuring proper scrolling behavior.

However, there are a few points I’d like to discuss with the maintainer. I would appreciate it if you could review and provide feedback.

PR

#4780

Result

Before

https://github.com/user-attachments/assets/e19c2ca2-9164-4641-9f67-3d041e8a2948

After

https://github.com/user-attachments/assets/8ceb9847-746c-4900-a55b-9d9affa2345b

confidential-nt avatar Sep 08 '24 05:09 confidential-nt

@manishoctal

Have you tried this solution? https://github.com/shadcn-ui/ui/issues/3959

I had a similar problem but solved it by adding modal={true} only to the Popover component.

<Popover modal={true} onOpenChange={setOpen} open={open}>
  xxxx
</Popover>

@confidential-nt Your PR is nice for solving this issue 👍 But in fact, the Select component is the same and is generated as a sibling element under the body tag when it is used under the Dialog. I mean, we have to solve the behavior of both Select and Popover I think.

:Note that: Select scrolling works correctly without modal={true} 🫤

bon10 avatar Oct 15 '24 08:10 bon10

@manishoctal

Have you tried this solution? #3959

I had a similar problem but solved it by adding modal={true} only to the Popover component.

<Popover modal={true} onOpenChange={setOpen} open={open}>
  xxxx
</Popover>

@confidential-nt Your PR is nice for solving this issue 👍 But in fact, the Select component is the same and is generated as a sibling element under the body tag when it is used under the Dialog. I mean, we have to solve the behavior of both Select and Popover I think.

:Note that: Select scrolling works correctly without modal={true} 🫤

Adding modal={true} to Popover worked for me

joshuarobs avatar Nov 01 '24 03:11 joshuarobs

@manishoctal

Have you tried this solution? #3959

I had a similar problem but solved it by adding modal={true} only to the Popover component.

<Popover modal={true} onOpenChange={setOpen} open={open}>
  xxxx
</Popover>

@confidential-nt Your PR is nice for solving this issue 👍 But in fact, the Select component is the same and is generated as a sibling element under the body tag when it is used under the Dialog. I mean, we have to solve the behavior of both Select and Popover I think.

:Note that: Select scrolling works correctly without modal={true} 🫤

worked for me too

jurmadani avatar Nov 03 '24 21:11 jurmadani

@manishoctal

Have you tried this solution? #3959

I had a similar problem but solved it by adding modal={true} only to the Popover component.

<Popover modal={true} onOpenChange={setOpen} open={open}>
  xxxx
</Popover>

@confidential-nt Your PR is nice for solving this issue 👍 But in fact, the Select component is the same and is generated as a sibling element under the body tag when it is used under the Dialog. I mean, we have to solve the behavior of both Select and Popover I think.

:Note that: Select scrolling works correctly without modal={true} 🫤

this worked perfectly... Bless you

Earnstein avatar Jan 27 '25 18:01 Earnstein

@manishoctal

Have you tried this solution? #3959

I had a similar problem but solved it by adding modal={true} only to the Popover component.

<Popover modal={true} onOpenChange={setOpen} open={open}>
  xxxx
</Popover>

@confidential-nt Your PR is nice for solving this issue 👍 But in fact, the Select component is the same and is generated as a sibling element under the body tag when it is used under the Dialog. I mean, we have to solve the behavior of both Select and Popover I think.

:Note that: Select scrolling works correctly without modal={true} 🫤

worked for me too

Rodrigues-Joao avatar Mar 19 '25 18:03 Rodrigues-Joao

@manishoctal

Have you tried this solution? #3959

I had a similar problem but solved it by adding modal={true} only to the Popover component.

<Popover modal={true} onOpenChange={setOpen} open={open}>
  xxxx
</Popover>

@confidential-nt Your PR is nice for solving this issue 👍 But in fact, the Select component is the same and is generated as a sibling element under the body tag when it is used under the Dialog. I mean, we have to solve the behavior of both Select and Popover I think.

:Note that: Select scrolling works correctly without modal={true} 🫤

This is work for me too

fiqriachmada avatar Apr 23 '25 15:04 fiqriachmada

Thank you! I've been searching for a solution for quite some time, and this implementation worked for me.

eswar-7116 avatar Jun 02 '25 19:06 eswar-7116

This is great, thank you for the fix.

cgensheimer avatar Jul 12 '25 02:07 cgensheimer

Wow, I really should have scrolled through this thread instead of spending half my life debugging code that wasn’t even broken. Next time, I’ll let the thread do the heavy lifting, and save myself a few gray hairs.

phalla-doll avatar Jul 19 '25 17:07 phalla-doll

@manishoctal

Have you tried this solution? #3959

I had a similar problem but solved it by adding modal={true} only to the Popover component.

<Popover modal={true} onOpenChange={setOpen} open={open}>
  xxxx
</Popover>

@confidential-nt Your PR is nice for solving this issue 👍 But in fact, the Select component is the same and is generated as a sibling element under the body tag when it is used under the Dialog. I mean, we have to solve the behavior of both Select and Popover I think.

:Note that: Select scrolling works correctly without modal={true} 🫤

may the creator bless you. Thanks.

MejanH avatar Aug 02 '25 16:08 MejanH

@manishoctal

Have you tried this solution? #3959

I had a similar problem but solved it by adding modal={true} only to the Popover component.

<Popover modal={true} onOpenChange={setOpen} open={open}>
  xxxx
</Popover>

@confidential-nt Your PR is nice for solving this issue 👍 But in fact, the Select component is the same and is generated as a sibling element under the body tag when it is used under the Dialog. I mean, we have to solve the behavior of both Select and Popover I think.

:Note that: Select scrolling works correctly without modal={true} 🫤

thanks i was trying a many things, reinstalling components, resetting css...i spent hours in this because i had others project with the same context and works fine, but the last happened this... and it was something so simple, thank you

Aszurar avatar Sep 13 '25 06:09 Aszurar