Skip to content

Commit 47939cf

Browse files
authored
Menu: constrain to a maximum of maxHeight
1 parent 060d7d0 commit 47939cf

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/components/Menu.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,13 @@ export function getMenuPlacement({
131131
if (placement === 'auto' || isFixedPosition) {
132132
// may need to be constrained after flipping
133133
let constrainedHeight = maxHeight;
134+
const spaceAbove = isFixedPosition ? viewSpaceAbove : scrollSpaceAbove;
134135

135-
if (
136-
(!isFixedPosition && scrollSpaceAbove >= minHeight) ||
137-
(isFixedPosition && viewSpaceAbove >= minHeight)
138-
) {
139-
constrainedHeight = isFixedPosition
140-
? viewSpaceAbove - marginBottom - spacing.controlHeight
141-
: scrollSpaceAbove - marginBottom - spacing.controlHeight;
136+
if (spaceAbove >= minHeight) {
137+
constrainedHeight = Math.min(
138+
spaceAbove - marginBottom - spacing.controlHeight,
139+
maxHeight
140+
);
142141
}
143142

144143
return { placement: 'top', maxHeight: constrainedHeight };

0 commit comments

Comments
 (0)