You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a Dialog is opened, it applies a .sl-scroll-lock class to the body element which sets overflow: hidden.
This causes the scrollbar to disappear which causes the body content to slide to the right by 16px. Users have told me this a bit jarring.
Browser / OS
OS: Windows 10
Browser: Chrome
Browser version: Version 108.0.5359.125 (Official Build) (64-bit)
(I've also tested this on Firefox and Edge, and the same issue appears)
Additional information
I've found a possible workaround but this has a side effect of snapping the viewport back to the top of the body content which is less than ideal.
This is another workaround that sort of works but would not work depending on scrollbar width between browsers / devices:
.sl-scroll-lock {
padding-right:16px;
}
I'm wondering if there's a better solution for locking the scrolling that doesn't have this side effect, maybe through JavaScript blocking scrolling events? I don't do much front-end stuff so forgive me if that is a dumb question haha.
Screenshots
Before:
After:
The text was updated successfully, but these errors were encountered:
After doing some research, I decided to use the same approach as Bootstrap which is to measure the scrollbar width and apply that value padding on the body. However, I'm using a CSS custom property called --sl-scroll-lock-size and the sl-scroll-lock class to avoid collisions and prevent breaking style properties that might change while scrolling is locked.
Since Bootstrap is more of a framework, they have two helpers for fixed/sticky elements. Shoelace doesn't have those opinions [yet], but you can adjust for fixed/sticky elements yourself by tapping into the --sl-scroll-lock-size custom property to apply a negative margin. (That custom property will only be set on the <body> when scrolling is locked.)
Fixed in 511182b. This will be available in the next release.
Describe the bug
When a Dialog is opened, it applies a
.sl-scroll-lock
class to the body element which setsoverflow: hidden
.This causes the scrollbar to disappear which causes the body content to slide to the right by 16px. Users have told me this a bit jarring.
Browser / OS
(I've also tested this on Firefox and Edge, and the same issue appears)
Additional information
I've found a possible workaround but this has a side effect of snapping the viewport back to the top of the body content which is less than ideal.
This is another workaround that sort of works but would not work depending on scrollbar width between browsers / devices:
I'm wondering if there's a better solution for locking the scrolling that doesn't have this side effect, maybe through JavaScript blocking scrolling events? I don't do much front-end stuff so forgive me if that is a dumb question haha.
Screenshots
Before:
After:
The text was updated successfully, but these errors were encountered: