Skip to content

Commit

Permalink
fix: allow for scrolling long menus (#3709)
Browse files Browse the repository at this point in the history
Co-authored-by: Nora Krantz <[email protected]>
  • Loading branch information
SiTaggart and nkrantz authored Jan 11, 2024
1 parent ed0f03a commit ba0d7bc
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/ninety-penguins-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@twilio-paste/menu": patch
"@twilio-paste/core": patch
---

[Menu]: Adds overflow scrolling behaviour on menus with a large number of items in, currently defaulting to 10 items
3 changes: 3 additions & 0 deletions packages/paste-core/components/menu/src/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ const StyledMenu = React.forwardRef<HTMLDivElement, BoxElementProps>(({ style, .
borderColor="colorBorderWeaker"
borderRadius="borderRadius30"
boxShadow="shadow"
// scroll at roughly 10 items
maxHeight="size40"
maxWidth="size30"
minWidth="size20"
overflowY="auto"
zIndex="zIndex20"
paddingY="space30"
_focus={{ outline: "none" }}
Expand Down
20 changes: 20 additions & 0 deletions packages/paste-core/components/menu/stories/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { StoryFn } from "@storybook/react";
import { Box } from "@twilio-paste/box";
import { AttachIcon } from "@twilio-paste/icons/esm/AttachIcon";
import { ChevronDownIcon } from "@twilio-paste/icons/esm/ChevronDownIcon";
Expand Down Expand Up @@ -457,3 +458,22 @@ export const AutoPlacementMenuStory = (): React.ReactNode => {
};

AutoPlacementMenuStory.storyName = "auto placed menu";

export const ManyItemsMenu: StoryFn = () => {
const menu = useMenuState({ visible: true });

return (
<>
<MenuButton {...menu} variant="primary">
Many items <ChevronDownIcon decorative />
</MenuButton>
<Menu {...menu} aria-label="Preferences">
{Array.from(new Array(100).keys()).map((item) => (
<MenuItem {...menu} key={item}>
Item {item}
</MenuItem>
))}
</Menu>
</>
);
};

1 comment on commit ba0d7bc

@vercel
Copy link

@vercel vercel bot commented on ba0d7bc Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.