Skip to content

Commit

Permalink
Merge pull request #3205 from answerrocket/menu-flip-constraint
Browse files Browse the repository at this point in the history
Menu: constrain to a maximum of maxHeight
  • Loading branch information
gwyneplaine authored Jan 3, 2019
2 parents 5094666 + 47939cf commit 97be94d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/components/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,13 @@ export function getMenuPlacement({
if (placement === 'auto' || isFixedPosition) {
// may need to be constrained after flipping
let constrainedHeight = maxHeight;
const spaceAbove = isFixedPosition ? viewSpaceAbove : scrollSpaceAbove;

if (
(!isFixedPosition && scrollSpaceAbove >= minHeight) ||
(isFixedPosition && viewSpaceAbove >= minHeight)
) {
constrainedHeight = isFixedPosition
? viewSpaceAbove - marginBottom - spacing.controlHeight
: scrollSpaceAbove - marginBottom - spacing.controlHeight;
if (spaceAbove >= minHeight) {
constrainedHeight = Math.min(
spaceAbove - marginBottom - spacing.controlHeight,
maxHeight
);
}

return { placement: 'top', maxHeight: constrainedHeight };
Expand Down

0 comments on commit 97be94d

Please sign in to comment.