diff --git a/front-packages/akeneo-design-system/src/components/Table/Table.stories.mdx b/front-packages/akeneo-design-system/src/components/Table/Table.stories.mdx index 4e7917bd591f..26bba1b2f0df 100644 --- a/front-packages/akeneo-design-system/src/components/Table/Table.stories.mdx +++ b/front-packages/akeneo-design-system/src/components/Table/Table.stories.mdx @@ -376,7 +376,7 @@ To compare information, for example how many products are completed versus how m {args => { - const [selectedLines, setSelectedLines] = useState([2]); + const [selectedLines, setSelectedLines] = useState([2, 3]); const handleToggleSelected = lineId => { if (selectedLines.indexOf(lineId) === -1) { setSelectedLines([...selectedLines, lineId]); @@ -410,7 +410,7 @@ To compare information, for example how many products are completed versus how m key={row.id} onClick={() => handleClick(row.id)} onSelectToggle={() => handleToggleSelected(row.id)} - isSelected={selectedLines.indexOf(row.id) !== -1} + isSelected={selectedLines.indexOf(row.id) !== -1 ? (row.id == 3 ? 'mixed' : true) : false} > The alt diff --git a/front-packages/akeneo-design-system/src/components/Table/TableRow/TableRow.tsx b/front-packages/akeneo-design-system/src/components/Table/TableRow/TableRow.tsx index 29d5ef8b5ed8..90df869dcfcf 100644 --- a/front-packages/akeneo-design-system/src/components/Table/TableRow/TableRow.tsx +++ b/front-packages/akeneo-design-system/src/components/Table/TableRow/TableRow.tsx @@ -132,7 +132,7 @@ type TableRowProps = Override< /** * Define if the row is selected, required when table is selectable */ - isSelected?: boolean; + isSelected?: boolean | 'mixed'; /** * Define if the row has a warning @@ -165,7 +165,7 @@ const TableRow = forwardRef( ( { rowIndex = 0, - isSelected, + isSelected = false, level, onSelectToggle, onClick, @@ -228,7 +228,7 @@ const TableRow = forwardRef( onClick={handleCheckboxChange} > { handleCheckboxChange(e); }} diff --git a/front-packages/akeneo-design-system/src/components/Table/TableRow/TableRow.unit.tsx b/front-packages/akeneo-design-system/src/components/Table/TableRow/TableRow.unit.tsx index da595e09469f..8b97579f6853 100644 --- a/front-packages/akeneo-design-system/src/components/Table/TableRow/TableRow.unit.tsx +++ b/front-packages/akeneo-design-system/src/components/Table/TableRow/TableRow.unit.tsx @@ -75,27 +75,6 @@ test('it throws when onSelectToggle is not given on selectable table', () => { mockConsole.mockRestore(); }); -test('it throws when isSelected is not given on selectable table', () => { - const mockConsole = jest.spyOn(console, 'error').mockImplementation(); - - const onSelectToggle = jest.fn(); - const cellRender = () => - render( - - - - A value - Another value - - -
- ); - - expect(cellRender).toThrowError(); - - mockConsole.mockRestore(); -}); - test('Table.Row supports forwardRef', () => { const ref = {current: null}; render(