Skip to content

Commit 5218263

Browse files
authored
react-material: Replace deprecated ListItem button prop (#2437)
Remove deprecated prop button of ListItem and use ListItemButton instead.
1 parent 9a60420 commit 5218263

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

packages/material-renderers/src/additional/ListWithDetailMasterItem.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { withJsonFormsMasterListItemProps } from '@jsonforms/react';
2727
import {
2828
Avatar,
2929
IconButton,
30-
ListItem,
30+
ListItemButton,
3131
ListItemAvatar,
3232
ListItemSecondaryAction,
3333
ListItemText,
@@ -48,7 +48,7 @@ export const ListWithDetailMasterItem = ({
4848
disableRemove,
4949
}: StatePropsOfMasterItem) => {
5050
return (
51-
<ListItem button selected={selected} onClick={handleSelect(index)}>
51+
<ListItemButton selected={selected} onClick={handleSelect(index)}>
5252
<ListItemAvatar>
5353
<Avatar aria-label='Index'>{index + 1}</Avatar>
5454
</ListItemAvatar>
@@ -70,7 +70,7 @@ export const ListWithDetailMasterItem = ({
7070
</Tooltip>
7171
</ListItemSecondaryAction>
7272
)}
73-
</ListItem>
73+
</ListItemButton>
7474
);
7575
};
7676

packages/material-renderers/test/renderers/MaterialListWithDetailRenderer.test.tsx

+17-15
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import MaterialListWithDetailRenderer, {
3838
import Enzyme, { mount, ReactWrapper } from 'enzyme';
3939
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
4040
import { JsonFormsStateProvider } from '@jsonforms/react';
41-
import { ListItem, Typography } from '@mui/material';
41+
import { ListItemButton, Typography } from '@mui/material';
4242
import { initCore, testTranslator } from './util';
4343
import { checkTooltip, checkTooltipTranslation } from './tooltipChecker';
4444

@@ -179,8 +179,8 @@ describe('Material list with detail renderer', () => {
179179
</JsonFormsStateProvider>
180180
);
181181

182-
const lis = wrapper.find('li');
183-
expect(lis).toHaveLength(2);
182+
const listItemButtons = wrapper.find('div[role="button"]');
183+
expect(listItemButtons).toHaveLength(2);
184184
});
185185
it('should render empty entries', () => {
186186
const core = initCore(schema, uischema, []);
@@ -364,8 +364,8 @@ describe('Material list with detail renderer', () => {
364364

365365
wrapper.update();
366366

367-
const lis = wrapper.find('li');
368-
expect(lis).toHaveLength(3);
367+
const listItemButtons = wrapper.find('div[role="button"]');
368+
expect(listItemButtons).toHaveLength(3);
369369
});
370370

371371
it('remove data from the array', () => {
@@ -378,14 +378,14 @@ describe('Material list with detail renderer', () => {
378378
</JsonFormsStateProvider>
379379
);
380380

381-
expect(wrapper.find(ListItem)).toHaveLength(2);
381+
expect(wrapper.find(ListItemButton)).toHaveLength(2);
382382

383383
const removeButton = wrapper.find('button').at(1);
384384
removeButton.simulate('click');
385385
wrapper.update();
386386

387-
const lis = wrapper.find(ListItem);
388-
expect(lis).toHaveLength(1);
387+
const listItemButtons = wrapper.find(ListItemButton);
388+
expect(listItemButtons).toHaveLength(1);
389389
});
390390

391391
it('should render first simple property', () => {
@@ -398,12 +398,14 @@ describe('Material list with detail renderer', () => {
398398
</JsonFormsStateProvider>
399399
);
400400

401-
expect(wrapper.find(ListItem)).toHaveLength(2);
401+
expect(wrapper.find(ListItemButton)).toHaveLength(2);
402402

403-
expect(wrapper.find(ListItem).find(Typography).at(0).text()).toBe(
403+
expect(wrapper.find(ListItemButton).find(Typography).at(0).text()).toBe(
404404
'El Barto was here'
405405
);
406-
expect(wrapper.find(ListItem).find(Typography).at(1).text()).toBe('Yolo');
406+
expect(wrapper.find(ListItemButton).find(Typography).at(1).text()).toBe(
407+
'Yolo'
408+
);
407409
});
408410

409411
it('should render first simple enum property as translated child label', () => {
@@ -419,15 +421,15 @@ describe('Material list with detail renderer', () => {
419421
</JsonFormsStateProvider>
420422
);
421423

422-
expect(wrapper.find(ListItem)).toHaveLength(3);
424+
expect(wrapper.find(ListItemButton)).toHaveLength(3);
423425

424-
expect(wrapper.find(ListItem).find(Typography).at(0).text()).toBe(
426+
expect(wrapper.find(ListItemButton).find(Typography).at(0).text()).toBe(
425427
'MSG_TYPE_1'
426428
);
427-
expect(wrapper.find(ListItem).find(Typography).at(1).text()).toBe(
429+
expect(wrapper.find(ListItemButton).find(Typography).at(1).text()).toBe(
428430
'MSG_TYPE_2'
429431
);
430-
expect(wrapper.find(ListItem).find(Typography).at(2).text()).toBe('');
432+
expect(wrapper.find(ListItemButton).find(Typography).at(2).text()).toBe('');
431433
});
432434

433435
it('should have no data message when no translator set', () => {

0 commit comments

Comments
 (0)