Skip to content

Commit 4e4c5ec

Browse files
Support overflow scrolling in ActionMenu (#3926)
* support overflow scrolling when maxHeight is set * pass overflow behavior in as a prop * only set overflow if prop is provided * changeset * update snapshot * keep overflow hidden as default style
1 parent caa91bb commit 4e4c5ec

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

.changeset/ninety-brooms-speak.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': patch
3+
---
4+
5+
Allow overflow scrolling to be controlled via an optional `overflow` property on Overlay

src/ActionMenu/ActionMenu.examples.stories.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,23 @@ export const OnRightSide = () => (
340340
</ActionMenu>
341341
)
342342

343+
export const SettingMaxHeight = () => {
344+
return (
345+
<ActionMenu>
346+
<ActionMenu.Button>Open menu</ActionMenu.Button>
347+
<ActionMenu.Overlay width="auto" maxHeight="large" overflow="auto">
348+
<ActionList>
349+
{Array.from({length: 100}, (_, i) => (
350+
<ActionList.Item key={`item-${i}`} onSelect={() => alert(`Item ${i + 1} clicked`)}>
351+
Item {i + 1}
352+
</ActionList.Item>
353+
))}
354+
</ActionList>
355+
</ActionMenu.Overlay>
356+
</ActionMenu>
357+
)
358+
}
359+
343360
export const OnlyInactiveItems = () => (
344361
<ActionMenu>
345362
<ActionMenu.Button inactive>Open menu</ActionMenu.Button>

src/Overlay/Overlay.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type StyledOverlayProps = {
1717
maxHeight?: keyof Omit<typeof heightMap, 'auto' | 'initial'>
1818
maxWidth?: keyof Omit<typeof widthMap, 'auto'>
1919
visibility?: 'visible' | 'hidden'
20+
overflow?: 'auto' | 'hidden' | 'scroll' | 'visible'
2021
anchorSide?: AnchorSide
2122
} & SxProp
2223

@@ -64,7 +65,7 @@ const StyledOverlay = styled.div<StyledOverlayProps>`
6465
max-height: ${props => props.maxHeight && heightMap[props.maxHeight]};
6566
width: ${props => widthMap[props.width || 'auto']};
6667
border-radius: 12px;
67-
overflow: hidden;
68+
overflow: ${props => (props.overflow ? props.overflow : 'hidden')};
6869
animation: overlay-appear ${animationDuration}ms ${get('animation.easeOutCubic')};
6970
7071
@keyframes overlay-appear {

0 commit comments

Comments
 (0)