Skip to content

Commit f295d3b

Browse files
imxvsunmozongmj12albertmichelengelen
authored
[data grid] Inherit icon fontSize from baseIconButton size (mui#22187)
Co-authored-by: sunmozong <sunmozong@kuaishou.com> Co-authored-by: Albert Yu <albert@albertyu.co> Co-authored-by: Michel Engelen <32863416+michelengelen@users.noreply.github.com>
1 parent db6df78 commit f295d3b

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

packages/x-data-grid/src/components/cell/GridActionsCellItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const GridActionsCellItem = forwardRef<HTMLElement, GridActionsCellItemProps>((p
4848
{...rootProps.slotProps?.baseIconButton}
4949
ref={ref as React.RefObject<HTMLButtonElement>}
5050
>
51-
{React.cloneElement(icon!, { fontSize: 'small' })}
51+
{React.cloneElement(icon!, { fontSize: 'inherit' })}
5252
</rootProps.slots.baseIconButton>
5353
);
5454
}

packages/x-data-grid/src/tests/rows.DataGrid.test.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import {
1111
} from '@mui/internal-test-utils';
1212
import clsx from 'clsx';
1313
import { spy, stub } from 'sinon';
14+
import { iconButtonClasses } from '@mui/material/IconButton';
1415
import Portal from '@mui/material/Portal';
16+
import SvgIcon, { svgIconClasses } from '@mui/material/SvgIcon';
1517
import {
1618
DataGrid,
1719
type DataGridProps,
@@ -317,6 +319,27 @@ describe('<DataGrid /> - Rows', () => {
317319
expect(screen.queryByText('print')).to.equal(null);
318320
});
319321

322+
it('should let the icon inherit the action button size', () => {
323+
render(
324+
<TestCase
325+
getActions={() => [
326+
<GridActionsCellItem
327+
key={1}
328+
icon={<SvgIcon data-testid="delete-icon" />}
329+
label="delete"
330+
size="large"
331+
/>,
332+
]}
333+
/>,
334+
);
335+
336+
const actionButton = screen.getByRole('menuitem', { name: 'delete' });
337+
const icon = screen.getByTestId('delete-icon');
338+
339+
expect(actionButton).to.have.class(iconButtonClasses.sizeLarge);
340+
expect(icon).to.have.class(svgIconClasses.fontSizeInherit);
341+
});
342+
320343
it('should show in a menu the actions marked as showInMenu', async () => {
321344
const { user } = render(
322345
<TestCase

0 commit comments

Comments
 (0)