diff --git a/packages/react-select/src/internal/useScrollLock.ts b/packages/react-select/src/internal/useScrollLock.ts index 150a0a6f99..3ee6d08c47 100644 --- a/packages/react-select/src/internal/useScrollLock.ts +++ b/packages/react-select/src/internal/useScrollLock.ts @@ -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) { @@ -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;