Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: menuShouldBlockScroll now applies the correct right-padding #6004

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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