react-remove-scroll is shifting my fixed header every time a radix select is opened #1586
-
I've seen #1340 and #1100 and updating radix select to 1.0.0 doesn't fix the issue. Seeing this on Mac and Windows on all browsers. Note that |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 13 replies
-
Hi @jtabone16, This is due to how We have to do it to our sidenav in our own docs for the same reason: |
Beta Was this translation helpful? Give feedback.
-
Hi All - I've just bumped into this as well, and have also noticed that either
Since that var is available, I'm assuming (safely?) that it could be used to create a custom class with additional padding added to fixed elements as required in order to prevent the shift? In our case, we import our Radix controls via a uikit in a monorepo, and so would prefer not to import the And so instead we created a utility class that we can apply to fixed elements - like a fixed header, as follows: .fix-scroll-layout-shift-right {
padding-right: var(--removed-body-scroll-bar-size);
}
.fix-scroll-layout-shift-left {
padding-left: var(--removed-body-scroll-bar-size);
} Are we miles out? Or does this look okay? |
Beta Was this translation helpful? Give feedback.
-
@benoitgrelard this is obviously a recurring annoyance... Throwing out there $0.02: I think that Radix should in-house the scrollbar offset vs. relying on a third-party deps for something like this, and then provide devs with options for greater control. In my case I set scrollbars to always appear on the body so there is no "jump" when navigating between pages (e.g. one long enough to have a scroll vs. one that doesn't have a scroll). This is especially noticeable for PC users with a fat scrollbar. It neatly solves jank with modals etc. as well (except when using certain libs... including radix) This simple trick also solves jank caused by modals hiding scrollbars when a layout's full-width backgrounds don't "stretch" to under the scrollbar (e.g. nav, body, footer different colours) (when this trick is done with a supporting modal implementation that can be configured to not hide the scrollbar and just lock the scroll so there is no jank / jump). Following through chains of issues and discussions is a bit of a pain and from Google this comes up again and again IMHO this is a sign that more flexible support is a requirement to be embraced :) As a headless library meant to provide devs with drop-in a11y improvements to their project, I think it is in line with my understanding of the project goals, and enables radix to be better integrated with apps across Dialog, menus, etc. I suppose the same sentiment for first-class support includes for multiple/stacked modals and auto-triggered modals (such as session timeout warnings, or very "desktoppy" UX enterprise/business apps that might pop over with connectivity interruptions or important real-time business interruptions -- where there can be >1 even from totally different causes). I love radix and would love to be able to use it for everything! |
Beta Was this translation helpful? Give feedback.
-
Can someone please help me out? Why does Radix UI disables the scrolling when the dropdown is open? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
In my case, simply removing the html,
body {
width: 100%; /* <<< remove it */
height: 100%;
} |
Beta Was this translation helpful? Give feedback.
-
Any new solutions? |
Beta Was this translation helpful? Give feedback.
Hi @jtabone16,
This is due to how
react-remove-scroll
handles the scrollbar removal technique.When you have fixed elements, you have do add some additional classes to those elements to avoid them shifting.
We have to do it to our sidenav in our own docs for the same reason:
https://github.com/radix-ui/website/blob/8c5a605f07879131e0f7a7e3fd777bb3604672d1/pages/docs/design-system/overview/%5Bslug%5D.tsx#L34-L41