Skip to content

Commit b1d6830

Browse files
committed
fix: tests and use portalTarget instead of window height
1 parent 65a6add commit b1d6830

File tree

3 files changed

+10
-17
lines changed

3 files changed

+10
-17
lines changed

packages/ui/src/components/Menu/MenuContent.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -262,19 +262,12 @@ export const Menu = forwardRef(
262262
if (disclosureRef.current && placement === 'bottom' && !noShrink) {
263263
const disclosureRect = disclosureRef.current.getBoundingClientRect()
264264
const disclosureBottom = disclosureRect.bottom
265-
const windowSize = window.innerHeight
265+
const targetSize = portalTarget.getBoundingClientRect().bottom
266266
const availableSpace =
267-
windowSize - disclosureBottom - SPACE_DISCLOSURE_POPUP
268-
267+
targetSize - disclosureBottom - SPACE_DISCLOSURE_POPUP
269268
setPopupMaxHeight(`${availableSpace}px`)
270269
}
271-
}, [
272-
isVisible,
273-
portalTarget.scrollHeight,
274-
disclosureRef,
275-
placement,
276-
noShrink,
277-
])
270+
}, [isVisible, portalTarget, disclosureRef, placement, noShrink])
278271

279272
return (
280273
<StyledPopup

packages/ui/src/components/Menu/__stories__/Shrink.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Shrink.parameters = {
3030
docs: {
3131
description: {
3232
story:
33-
'When the menu is at the bottom of a page (with `placement = "bottom"`), it will shrink so that it does not cause overflow. It is possible to removet this feature using prop `noShrink`',
33+
'When the menu is at the bottom of a page (not possible to scroll down further), with `placement = "bottom"`, it will shrink so that it does not cause overflow. It is possible to remove this feature using prop `noShrink`',
3434
},
3535
},
3636
}

packages/ui/src/components/Tabs/__tests__/__snapshots__/index.test.tsx.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,7 +2266,7 @@ exports[`Tabs > renders correctly with Tabs with prop 1`] = `
22662266
text-align: center;
22672267
position: absolute;
22682268
max-width: 14.5rem;
2269-
max-height: 30rem;
2269+
max-height: -24px;
22702270
overflow: auto;
22712271
overflow-wrap: break-word;
22722272
font-size: 0.8rem;
@@ -2338,7 +2338,7 @@ exports[`Tabs > renders correctly with Tabs with prop 1`] = `
23382338
flex-direction: column;
23392339
overflow-y: auto;
23402340
overflow-x: hidden;
2341-
max-height: calc(30rem - 0.25rem);
2341+
max-height: calc(min(30rem, -24px) - 0.25rem);
23422342
background-color: #ffffff;
23432343
color: #3f4250;
23442344
border-radius: 0.25rem;
@@ -2521,7 +2521,7 @@ exports[`Tabs > renders correctly with Tabs with prop 1`] = `
25212521
text-align: center;
25222522
position: absolute;
25232523
max-width: 14.5rem;
2524-
max-height: 30rem;
2524+
max-height: -24px;
25252525
overflow: auto;
25262526
overflow-wrap: break-word;
25272527
font-size: 0.8rem;
@@ -2593,7 +2593,7 @@ exports[`Tabs > renders correctly with Tabs with prop 1`] = `
25932593
flex-direction: column;
25942594
overflow-y: auto;
25952595
overflow-x: hidden;
2596-
max-height: calc(30rem - 0.25rem);
2596+
max-height: calc(min(30rem, -24px) - 0.25rem);
25972597
background-color: #ffffff;
25982598
color: #3f4250;
25992599
border-radius: 0.25rem;
@@ -3469,7 +3469,7 @@ exports[`Tabs > renders correctly with Tabs with prop 1`] = `
34693469
text-align: center;
34703470
position: absolute;
34713471
max-width: 14.5rem;
3472-
max-height: 30rem;
3472+
max-height: -24px;
34733473
overflow: auto;
34743474
overflow-wrap: break-word;
34753475
font-size: 0.8rem;
@@ -3541,7 +3541,7 @@ exports[`Tabs > renders correctly with Tabs with prop 1`] = `
35413541
flex-direction: column;
35423542
overflow-y: auto;
35433543
overflow-x: hidden;
3544-
max-height: calc(30rem - 0.25rem);
3544+
max-height: calc(min(30rem, -24px) - 0.25rem);
35453545
background-color: #ffffff;
35463546
color: #3f4250;
35473547
border-radius: 0.25rem;

0 commit comments

Comments
 (0)