Skip to content

Commit

Permalink
Fix view height used for menu positioning (#5177)
Browse files Browse the repository at this point in the history
* Fix view height used for menu positioning

* Create friendly-icons-flow.md

* Format

* Reset yarn.lock
  • Loading branch information
Methuselah96 committed May 7, 2022
1 parent c963633 commit 1f140e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
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

0 comments on commit 1f140e4

Please sign in to comment.