Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions packages/react-select/src/internal/useScrollLock.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import { useCallback, useEffect, useRef } from 'react';

const STYLE_KEYS = [
'boxSizing',
'height',
'overflow',
'paddingRight',
'position',
] as const;
const STYLE_KEYS = ['boxSizing', 'height', 'overflow', 'position'] as const;

const LOCK_STYLES = {
boxSizing: 'border-box', // account for possible declaration `width: 100%;` on body
height: '100%',
overflow: 'hidden',
position: 'relative',
height: '100%',
};

function preventTouchMove(e: TouchEvent) {
Expand Down Expand Up @@ -83,8 +77,9 @@ export default function useScrollLock({

// apply the lock styles and padding if this is the first scroll lock
if (accountForScrollbars && activeScrollLocks < 1) {
const currentPadding =
parseInt(originalStyles.current.paddingRight, 10) || 0;
const currentPadding = parseInt(
window.getComputedStyle(document.body).paddingRight.slice(0, -2)
);
const clientWidth = document.body ? document.body.clientWidth : 0;
const adjustedPadding =
window.innerWidth - clientWidth + currentPadding || 0;
Expand Down