Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/ninety-brooms-speak.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Allow overflow scrolling to be controlled via an optional `overflow` property on Overlay
17 changes: 17 additions & 0 deletions src/ActionMenu/ActionMenu.examples.stories.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -340,6 +340,23 @@ export const OnRightSide = () => (
</ActionMenu>
)

export const SettingMaxHeight = () => {
return (
<ActionMenu>
<ActionMenu.Button>Open menu</ActionMenu.Button>
<ActionMenu.Overlay width="auto" maxHeight="large" overflow="auto">
<ActionList>
{Array.from({length: 100}, (_, i) => (
<ActionList.Item key={`item-${i}`} onSelect={() => alert(`Item ${i + 1} clicked`)}>
Item {i + 1}
</ActionList.Item>
))}
</ActionList>
</ActionMenu.Overlay>
</ActionMenu>
)
}

export const OnlyInactiveItems = () => (
<ActionMenu>
<ActionMenu.Button inactive>Open menu</ActionMenu.Button>
Expand Down
3 changes: 2 additions & 1 deletion src/Overlay/Overlay.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,7 @@ type StyledOverlayProps = {
maxHeight?: keyof Omit<typeof heightMap, 'auto' | 'initial'>
maxWidth?: keyof Omit<typeof widthMap, 'auto'>
visibility?: 'visible' | 'hidden'
overflow?: 'auto' | 'hidden' | 'scroll' | 'visible'
anchorSide?: AnchorSide
} & SxProp

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

@keyframes overlay-appear {
Expand Down