Closed arekrgw closed 2 weeks ago
As a temporary workaround for those of us using a right-aligned drawer, you can do this:
body[data-scroll-locked] {
padding-right: 15px !important;
}
Edit: only works though if the page has a scrollbar. If not, it'll push everything over 15px :/
Cam you provide a demo with reproduction?
Hey! I've created a reproduction highlighting the issue here:
Also experiencing this having to come to this from using shadcn
Also Experiencing this when using right or left aligned drawers
This is still an issue in 0.9.1.
The issue is that both html
and body
tags receive padding-right and margin-right, respectively.
I don't see any references to such styles in the repo, so is this coming from Radix/some dep? 🤷
The workaround would be to set !important
on either html
or (can't do on body
body
since there it is with !important
too) with styles.
New reproduction link (with 0.9.1) - https://stackblitz.com/edit/nextjs-j6eglw?file=app%2FDrawer.tsx @emilkowalski FYI
don't see any references to such styles in the repo, so is this coming from Radix/some dep? 🤷
It must be something in vaul, as when you use the radix library alone, there are no such issues with the scrollbar.
It must be something in vaul, as when you use the radix library alone, there are no such issues with the scrollbar.
Simple CTRL+F didn't find anything 🤔 Could it be that it was a bug in radix before, but now in latest version they have fixed it?
I investigated this problem further because as others have mentioned here, this problem doesn't occur on the radix dialog component.
I tried to see how the react-remove-scroll-bar library was running behind the scenes. It is this library that sets the --removed-body-scroll-bar-size
. To be more specific, it's the getGapWidth function inside utils.js.
The components difference is on document.documentElement.clientWidth
value. On the Radix Dialog component, this value is correct, but on the Drawer one is the same as window.innerWidth
which causes the value of the gap to be always 0.
The reason for these values to be the same is that vaul adds classes to the body which affect the clientWidth
value.
Then I figured to add the noBodyProps
prop, but the flickering problem remained. I found out another difference between the component, and that it was a class in <html>
, a padding-right
that was added when using the vaul component.
This padding was also added by vaul. Easy to remove though, by another prop: disablePreventScroll
.
So, by adding both of these props, you can remove the flicker effect when opening the drawer on the right (or left).
--
Anyway, I am not sure of the other effects of these props, as they may break other functionalities in some cases, but at the moment, this is a fine solution for me.
Yup, setting disablePreventScroll
and noBodyStyles
fixes the issue
This has been fixed now, the --removed-body-scroll-bar-size
CSS variable should now set the correct value automatically.
When opening normal radix dialog, css variable
--removed-body-scroll-bar-size
on body element is set to some pixel value that represents the scrollbar width when it hides. That's not the case with this lib Drawer, variable is set to 0px all the time, creating content shift on the pageTo reproduce you need to have to have some content on the page and then open the right/left drawer.
After some investigation it looks like the css
position
override tofixed
fromrelative
on body element is the issue.