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

Fix view height used for menu positioning #5177

Merged
merged 4 commits into from May 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/friendly-icons-flow.md
@@ -0,0 +1,5 @@
---
'react-select': patch
---

Fix view height used for menu positioning to be the scroll parent instead of the window
7 changes: 5 additions & 2 deletions packages/react-select/src/components/Menu.tsx
Expand Up @@ -12,9 +12,10 @@ import { createPortal } from 'react-dom';
import {
animatedScrollTo,
getBoundingClientObj,
RectType,
getScrollParent,
getScrollTop,
normalizedHeight,
RectType,
scrollTo,
} from '../utils';
import {
Expand Down Expand Up @@ -75,7 +76,9 @@ export function getMenuPlacement({
} = menuEl.getBoundingClientRect();

const { top: containerTop } = menuEl.offsetParent.getBoundingClientRect();
const viewHeight = window.innerHeight;
const viewHeight = isFixedPosition
? window.innerHeight
: normalizedHeight(scrollParent);
const scrollTop = getScrollTop(scrollParent);

const marginBottom = parseInt(getComputedStyle(menuEl).marginBottom, 10);
Expand Down