ui: [bug]: Select removes scrollbar

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

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

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 23
  • Comments: 15

Most upvoted comments

/* 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

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

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;
  } 

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! 😄

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

would be great to have a similar solution as the DropdownMenu component with the props modal={false}

https://www.radix-ui.com/primitives/docs/components/dropdown-menu#root

For me is not removing the scrollbar but adding the margin (causing layout shift) I fixed it with https://github.com/shadcn-ui/ui/issues/4227#issuecomment-2438290165