Skip to content

Commit 55909e8

Browse files
committed
Fix x-trap.noscroll layout shift conflict with scrollbar-gutter
1 parent 28a2aa8 commit 55909e8

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

packages/focus/src/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,16 @@ function disableScrolling() {
199199
let paddingRight = document.documentElement.style.paddingRight
200200

201201
let scrollbarWidth = window.innerWidth - document.documentElement.clientWidth
202+
let scrollbarGutter = window.getComputedStyle(document.documentElement).scrollbarGutter
202203

203204
document.documentElement.style.overflow = 'hidden'
205+
206+
if (scrollbarGutter && scrollbarGutter !== 'auto') {
207+
return () => {
208+
document.documentElement.style.overflow = overflow
209+
}
210+
}
211+
204212
document.documentElement.style.paddingRight = `${scrollbarWidth}px`
205213

206214
return () => {

0 commit comments

Comments
 (0)