Skip to content

Commit

Permalink
Fix x-trap.noscroll layout shift conflict with scrollbar-gutter
Browse files Browse the repository at this point in the history
  • Loading branch information
dotfrag committed Jan 27, 2025
1 parent 28a2aa8 commit a6b3581
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/focus/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,16 @@ function disableScrolling() {
let paddingRight = document.documentElement.style.paddingRight

let scrollbarWidth = window.innerWidth - document.documentElement.clientWidth
let scrollbarGutter = window.getComputedStyle(document.documentElement).scrollbarGutter

document.documentElement.style.overflow = 'hidden'

if (scrollbarGutter && scrollbarGutter !== 'auto') {
return () => {
document.documentElement.style.overflow = overflow
}
}

document.documentElement.style.paddingRight = `${scrollbarWidth}px`

return () => {
Expand Down

0 comments on commit a6b3581

Please sign in to comment.