shadcn-ui / ui

Beautifully designed components that you can copy and paste into your apps. Accessible. Customizable. Open Source.
https://ui.shadcn.com
MIT License
75.45k stars 4.73k forks source link

[bug]: Select removes scrollbar #4227

Open LuziferSenpai opened 4 months ago

LuziferSenpai commented 4 months ago

Describe the bug

When using a select somewhere and the body has a scrollbar, this scrollbar gets removed as soon as the select is used. showcase

Affected component/components

Select

How to reproduce

  1. Give the body a scrollbar
  2. Add a Select
  3. Open the Select

Codesandbox/StackBlitz link

No response

Logs

No response

System Info

Chrome

Before submitting

mustafaR35 commented 4 months ago

Hey I have a similar issue, where i cant scroll the content, any idea as to why that is ?

spencersablan commented 4 months ago

Hey friends 👋

This seems to be a known feature of the Radix UI select component. See this comment from a similar issue raised for Radix UI.

One thing you can try is using a popover instead of a select! 😄

Naitik2408 commented 4 months ago

Can you provide me exact path of the page where you find the issue.

LuziferSenpai commented 3 months ago

Can you provide me exact path of the page where you find the issue.

You just add a select to any project and open it, you see your scrollbar dissappearing

Emmanuel-Xs commented 2 months ago

yeah am having the same issue

how to make the scrollbar visible when the shadcnui select component is clicked on

osh6006 commented 1 month ago

I found a solution, but I don't know if it's the right way..

/* global.css */
  html body[data-scroll-locked] {
    --removed-body-scroll-bar-size: 0 !important;
    margin-right: 0 !important;
  } 
Pascalmh commented 1 month ago

Depending on your layout you'll need to add additional classes from react-remove-scroll-bar which is used internally for the radix-ui/primitives.

I needed to add the fullWidthClassName to my "main div" (the first child after the router outlet).

See also: https://github.com/radix-ui/primitives/discussions/1586#discussioncomment-3302669

Cloudyaa commented 1 month ago
/* global.css */
  html body[data-scroll-locked] {
    overflow: visible !important;
    margin-right: 0 !important;
  } 

This one worked for me - no layout shift and scroll still visible

armya-z commented 1 month ago

it doesnt fixed yet? select is a very usefull and this bug is make the whole package useless...