Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Menus): do not overflow divider #848

Merged
merged 2 commits into from
Jan 6, 2025
Merged
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
15 changes: 12 additions & 3 deletions stories/components/menus.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ const StyledMenu = styled(Menu)`
border: 1px solid black;
`;

/*
This is a styled version of MenuDivider.
By default, Blueprint adds a negative x-axis margin of -5px, which causes the Divider to overflow the Menu on the left and right.
We need to override this margin to 0 to prevent it from exceeding the Menu boundaries.
*/
const StyledMenuDivider = styled(MenuDivider)`
margin: 5px 0;
`;

export function WithIcon() {
const options = [
defaultOptions,
Expand Down Expand Up @@ -41,7 +50,7 @@ export function WithDivider() {
const options = useMemo(() => {
return [
defaultOptions,
<MenuDivider key="0" />,
<StyledMenuDivider key="0" />,
<MenuItem key="1" text="Exercise" />,
];
}, []);
Expand All @@ -55,11 +64,11 @@ export function Complex() {
<MenuItem text="Back" icon="book" />
<MenuItem text="Forward" icon="step-forward" disabled />
<MenuItem text="Refresh" icon="refresh" />
<MenuDivider />
<StyledMenuDivider />
<MenuItem text="Save as" icon="saved" />
<MenuItem text="Print" icon="print" />
<MenuItem text="Cast media to device" icon="video" />
<MenuDivider />
<StyledMenuDivider />
<MenuItem text="Send page to your devices" icon="add" />
<MenuItem text="Create QR Code for this page" icon="settings" />
</StyledMenu>
Expand Down
Loading