Skip to content

Commit 796f838

Browse files
tay1orjonesriddhybansalguidari
authored
fix(overflowmenu): always use button kind=ghost (#16970)
* fix(overflowmenu): always use button kind=ghost * chore: update snaps * chore: update snaps --------- Co-authored-by: Riddhi Bansal <[email protected]> Co-authored-by: Guilherme Datilio Ribeiro <[email protected]>
1 parent a6cb80d commit 796f838

File tree

6 files changed

+38
-5
lines changed

6 files changed

+38
-5
lines changed

packages/react/src/components/DataTable/__tests__/__snapshots__/DataTable-test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ exports[`DataTable behaves as expected selection should render and match snapsho
572572
aria-expanded="false"
573573
aria-haspopup="true"
574574
aria-labelledby="tooltip-:r2m:"
575-
class="cds--btn--icon-only cds--toolbar-action cds--overflow-menu cds--overflow-menu cds--overflow-menu--md cds--btn cds--btn--md cds--layout--size-md cds--btn--primary"
575+
class="cds--btn--icon-only cds--toolbar-action cds--overflow-menu cds--overflow-menu cds--overflow-menu--md cds--btn cds--btn--md cds--layout--size-md cds--btn--ghost"
576576
title="Settings"
577577
type="button"
578578
>
@@ -1003,7 +1003,7 @@ exports[`DataTable renders as expected - Component API should render and match s
10031003
aria-expanded="false"
10041004
aria-haspopup="true"
10051005
aria-labelledby="tooltip-:rk:"
1006-
class="cds--btn--icon-only cds--toolbar-action cds--overflow-menu cds--overflow-menu cds--overflow-menu--md cds--btn cds--btn--md cds--layout--size-md cds--btn--primary"
1006+
class="cds--btn--icon-only cds--toolbar-action cds--overflow-menu cds--overflow-menu cds--overflow-menu--md cds--btn cds--btn--md cds--layout--size-md cds--btn--ghost"
10071007
title="Settings"
10081008
type="button"
10091009
>

packages/react/src/components/DataTable/__tests__/__snapshots__/TableToolbarMenu-test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ exports[`TableToolbarMenu renders as expected - Component API should render 1`]
1515
aria-expanded="false"
1616
aria-haspopup="true"
1717
aria-labelledby="tooltip-:r0:"
18-
class="cds--btn--icon-only custom-class cds--toolbar-action cds--overflow-menu cds--overflow-menu cds--overflow-menu--md cds--btn cds--btn--md cds--layout--size-md cds--btn--primary"
18+
class="cds--btn--icon-only custom-class cds--toolbar-action cds--overflow-menu cds--overflow-menu cds--overflow-menu--md cds--btn cds--btn--md cds--layout--size-md cds--btn--ghost"
1919
title="Add"
2020
type="button"
2121
>

packages/react/src/components/OverflowMenu/OverflowMenu-test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,21 @@ describe('OverflowMenu', () => {
3737
expect(screen.getByRole('button')).toHaveAttribute('data-testid', 'test');
3838
});
3939

40+
it('should always use button kind=ghost', () => {
41+
render(
42+
<OverflowMenu
43+
data-testid="test"
44+
aria-label="Overflow menu"
45+
className="extra-class">
46+
<OverflowMenuItem className="test-child" itemText="one" />
47+
<OverflowMenuItem className="test-child" itemText="two" />
48+
</OverflowMenu>
49+
);
50+
51+
expect(screen.getByRole('button')).not.toHaveClass('cds--btn--primary');
52+
expect(screen.getByRole('button')).toHaveClass('cds--btn--ghost');
53+
});
54+
4055
it('should flip menu alignment', async () => {
4156
render(
4257
<OverflowMenu

packages/react/src/components/OverflowMenu/OverflowMenu.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,8 @@ class OverflowMenu extends React.Component<
732732
id={id}
733733
ref={mergeRefs(this._triggerRef, ref)}
734734
size={size}
735-
label={iconDescription}>
735+
label={iconDescription}
736+
kind="ghost">
736737
<IconElement {...iconProps} />
737738
</IconButton>
738739
{open && this.state.hasMountedTrigger && wrappedMenuBody}

packages/react/src/components/OverflowMenu/next/OverflowMenu-test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,22 @@ describe('OverflowMenu (enable-v12-overflowmenu)', () => {
8686
expect(container.firstChild).toHaveAttribute('id', 'custom-id');
8787
});
8888

89+
it('should always use button kind=ghost', () => {
90+
render(
91+
<OverflowMenu>
92+
<MenuItem label="item" className="test-child">
93+
one
94+
</MenuItem>
95+
<MenuItem label="item" className="test-child">
96+
two
97+
</MenuItem>
98+
</OverflowMenu>
99+
);
100+
101+
expect(screen.getByRole('button')).not.toHaveClass('cds--btn--primary');
102+
expect(screen.getByRole('button')).toHaveClass('cds--btn--ghost');
103+
});
104+
89105
it('should close menu on outside click', async () => {
90106
render(
91107
<OverflowMenu>

packages/react/src/components/OverflowMenu/next/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ const OverflowMenu = React.forwardRef<HTMLDivElement, OverflowMenuProps>(
189189
onMouseDown={handleMousedown}
190190
ref={floatingRef}
191191
label={label}
192-
align={tooltipAlignment}>
192+
align={tooltipAlignment}
193+
kind="ghost">
193194
<IconElement className={`${prefix}--overflow-menu__icon`} />
194195
</IconButton>
195196
<Menu

0 commit comments

Comments
 (0)