Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScrollArea not working inside a Popover #542

Closed
mattiaz9 opened this issue Jun 5, 2023 · 26 comments · May be fixed by #2123
Closed

ScrollArea not working inside a Popover #542

mattiaz9 opened this issue Jun 5, 2023 · 26 comments · May be fixed by #2123
Labels

Comments

@mattiaz9
Copy link

mattiaz9 commented Jun 5, 2023

This is a code example:

<Popover>
  <PopoverTrigger>Open</PopoverTrigger>
  <PopoverContent>
    <ScrollArea className="flex max-h-16 flex-col" type="always">
      <div className="h-[800px] bg-red-500" />
    </ScrollArea>
  </PopoverContent>
</Popover>

The scrollbar appears but the scroll isn't working inside the content, only when i'm hovering over the scrollbar itself.

@brooksa-chemtest
Copy link

I've found I have to set a height value for this to work. Try with just 'h-16' as a className.

Scrolling with the mouse wheel doesn't seem to work though.

@mattiaz9
Copy link
Author

Personally I fixed it by setting modal={true} to the Popover.
It's a weird behaviour I have to say..

@j-fdion
Copy link

j-fdion commented Jun 14, 2023

I had the same problem but reversed, a popover inside a scrollarea would not stay open. Using the setting modal={true} as stated by @mattiaz9 was my solution.

@henriqueup
Copy link

henriqueup commented Jul 31, 2023

Had the same problem using Commad and CommandList inside Popover. I had set overflow-y-auto and a max height on the CommandList. The scroll bar was showing and I could drag it, but scroll wheel was not working. When I pass modal={true} to the Popover, it scrolls normally. Setting height in CommandList didn't solve the problem.

@undesicimo
Copy link

@mattiaz9 Thank you for this. setting Popover to modal fixed it for me as well

@mamlzy
Copy link

mamlzy commented Oct 19, 2023

Personally I fixed it by setting modal={true} to the Popover. It's a weird behaviour I have to say..

Thank you so much, it works

@mununki
Copy link

mununki commented Nov 28, 2023

@mattiaz9 Thanks! It works.

@zwergdev
Copy link

@mattiaz9 thanks!

<Popover modal> 
  ....
    <ScrollArea>
      <CommandGroup>
        ....
      </CommandGroup>
    </ScrollArea>
  ....
</Popover>

@SergiuPlesco
Copy link

Try using "h-" instead of "max-h-" for setting the height of a scroll area.

@roylee0704
Copy link

if i have an empty list, "h-" wouldn't make sense.

I would love to be able to use "max-h-" unfortunately Its not working.

@ArmandFrvr
Copy link

For max-h, it needs to be set on the radix viewport, like this: <ScrollArea className={'[&>[data-radix-scroll-area-viewport]]:max-h-[300px]'}>

@mardrof
Copy link

mardrof commented Mar 26, 2024

@ArmandFrvr thanks for the solution. For me it works like a charm :)

pa4080 added a commit to pa4080/shadcn-ui that referenced this issue Apr 10, 2024
@krishnagkmit
Copy link

I had the same problem but reversed, a popover inside a scrollarea would not stay open. Using the setting modal={true} as stated by @mattiaz9 was my solution.

it worked for me, thanks @mattiaz9

@rafizuaf
Copy link

rafizuaf commented Jun 4, 2024

Personally I fixed it by setting modal={true} to the Popover. It's a weird behaviour I have to say..

thanks. worked for me

@iyy0v
Copy link

iyy0v commented Jun 4, 2024

Personally I fixed it by setting modal={true} to the Popover. It's a weird behaviour I have to say..

Worked for me, thanks!

@panzacoder
Copy link

Adding modal to Popover "works" for scrolling, but is a bad solution for my use-case.

I'm using Popover with a Scroll Area for search results that appear as you are typing. I can prevent focus from being pulled into the popover but if focus is given to the popover at all (by scroll, tapping, etc), I can no longer re-focus on my input, because the modal flag disables interaction everywhere else on the page.

@mikechabotcandy
Copy link

I can confirm the solution posted by @ArmandFrvr works when the ScrollArea is nested within a Drawer.

@shadcn shadcn added the Stale label Jun 21, 2024
@MehrdadArman
Copy link

Personally I fixed it by setting modal={true} to the Popover. It's a weird behaviour I have to say..

Thank you for your solution it worked for me like a charm :)

@shadcn
Copy link
Collaborator

shadcn commented Jul 20, 2024

This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.

@shadcn shadcn closed this as completed Jul 20, 2024
@mamunur13525
Copy link

mamunur13525 commented Jul 25, 2024

Personally I fixed it by setting modal={true} to the Popover. It's a weird behaviour I have to say..

Thanks. It works for me.

@yoosion030
Copy link

Scrolling still does not work in the iPad Chrome environment.
Has anyone experienced the same phenomenon as me?

@krishnagkmit
Copy link

Scrolling still does not work in the iPad Chrome environment. Has anyone experienced the same phenomenon as me?

working for me
is there a specific way to reproduce the effect?

@andreidionisie
Copy link

Adding modal to Popover "works" for scrolling, but is a bad solution for my use-case.

I'm using Popover with a Scroll Area for search results that appear as you are typing. I can prevent focus from being pulled into the popover but if focus is given to the popover at all (by scroll, tapping, etc), I can no longer re-focus on my input, because the modal flag disables interaction everywhere else on the page.

@panzacoder , did you find the answer? I faced the similar issue.

@oxuk85
Copy link

oxuk85 commented Sep 10, 2024

Has anyone overcome this issue when the popover is part of a modal/dialog?

I had the property modal={true} already set so I am not sure what the fix would be.

Any help would be much appreciated!

<Popover modal open={popoverOpen} onOpenChange={setPopoverOpen}>
  ...
  <PopoverContent className="w-auto p-2" align="center">
    <ScrollArea className={"[&>[data-radix-scroll-area-viewport]]:max-h-[300px]" >
    ...
    </ScrollArea>
  </PopoverContent>
</Popover>

@trungsky
Copy link

Personally I fixed it by setting modal={true} to the Popover. It's a weird behaviour I have to say..

Thanks! It works

@MonaroDaniel
Copy link

It worked, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.