fix(theme): avoid layout shift caused by scrollbar #1568
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #1054
Previously, the disappearance of non-overlay scrollbars (the default for Chromium on Windows and Linux) changed width of the
body
element and its descendants, causing the whole page to shift slightly to right. This occurred in two cases:This change avoids the shift by using by
100vw
(which isn't changed by the presence of a scrollbar) instead of100%
where appropriate.Tested in Firefox and Chromium on Linux, could use a quick test on Safari with MacOS set to always show scrollbars.
Some caveats:
>= 768px
to avoid the scrollbar from overlapping the UI on smaller screens (the search modal becomes fullscreen at this size, so the shift is only visible in case 2 above)body
to avoid a horizontal scrollbarI initially tried using the
scrollbar-gutter
rule but ran into trouble getting the modal backdrop and other content overlap the gutter. Then I tried using#app
as the scroll container instead ofhtml
but that broke a lot of things 馃ゲ.Also, is the
is-home
class needed onVPContent
? I couldn't figure out what effect it had and needed to override it anyways to get the other rule to work, so hopefully it is okay I removed it.