Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit 30d170f

Browse files
boilundTigge
authored andcommitted
fix(menu): export MenuButton and menu button jumps
Export MenuButton again. MenuButton should be exported but it was accidentally removed when refactoring BaseMenu. Also added example in docs. And fixed menu button that jumps when changing state by adding `box-sizing: border-box`.
1 parent b34ba50 commit 30d170f

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

packages/core/src/Menu/BaseMenu.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const Anchor = styled.div`
3636

3737
export const MenuButtonIconContainer = styled.div`
3838
position: relative;
39+
box-sizing: border-box;
3940
height: ${componentSize.small};
4041
width: ${componentSize.small};
4142
border-radius: ${shape.radius.circle};
@@ -199,7 +200,7 @@ interface MenuButtonProps extends BaseButtonProps {
199200
readonly title?: string
200201
}
201202

202-
const MenuButton = React.forwardRef<BaseButtonElement, MenuButtonProps>(
203+
export const MenuButton = React.forwardRef<BaseButtonElement, MenuButtonProps>(
203204
(
204205
{
205206
disabled,

packages/core/src/Menu/__snapshots__/index.test.tsx.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ exports[`Menus Menu (default) 1`] = `
6161
6262
.c5 {
6363
position: relative;
64+
box-sizing: border-box;
6465
height: 32px;
6566
width: 32px;
6667
border-radius: 50%;
@@ -279,6 +280,7 @@ exports[`Menus Menu (disabled) 1`] = `
279280
280281
.c5 {
281282
position: relative;
283+
box-sizing: border-box;
282284
height: 32px;
283285
width: 32px;
284286
border-radius: 50%;
@@ -501,6 +503,7 @@ exports[`Menus Menu (left) 1`] = `
501503
502504
.c5 {
503505
position: relative;
506+
box-sizing: border-box;
504507
height: 32px;
505508
width: 32px;
506509
border-radius: 50%;
@@ -719,6 +722,7 @@ exports[`Menus Menu (right) 1`] = `
719722
720723
.c5 {
721724
position: relative;
725+
box-sizing: border-box;
722726
height: 32px;
723727
width: 32px;
724728
border-radius: 50%;

packages/docs/src/mdx/coreComponents/Menu.mdx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,31 @@ export const ITEMS = [
8484
/>
8585
```
8686

87+
## Advanced usage
88+
89+
You can create a custom `Menu` with `MenuButton`.
90+
91+
```typescript
92+
<Anchor ref={anchorRef}>
93+
<MenuButton onClick={mouseToggleMenu}>
94+
<MenuButtonIconContainer>
95+
<MenuButtonIcon icon={icon} />
96+
<MenuButtonHalo />
97+
</MenuButtonIconContainer>
98+
</MenuButton>
99+
{menuVisible ? (
100+
<PopOver
101+
horizontalPosition="right"
102+
horizontalAlignment="right"
103+
anchorEl={anchorRef.current}
104+
onScroll={hideAndBlurMenu}
105+
>
106+
<MenuWrapper onClose={hideMenu}>{children}</MenuWrapper>
107+
</PopOver>
108+
) : null}
109+
</Anchor>
110+
```
111+
87112
## Menu Props
88113

89114
Menu forwards all props to `PopOver`.

0 commit comments

Comments
 (0)