Skip to content

Commit 4dc5cbe

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

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/focus/src/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,18 @@ 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+
// null change to trigger gh action
207+
208+
if (scrollbarGutter && scrollbarGutter !== 'auto') {
209+
return () => {
210+
document.documentElement.style.overflow = overflow
211+
}
212+
}
213+
204214
document.documentElement.style.paddingRight = `${scrollbarWidth}px`
205215

206216
return () => {

0 commit comments

Comments
 (0)