Skip to content

Commit

Permalink
Fix rowClasses API not supporting multiple space-separated classes
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Oct 20, 2023
1 parent 7b9c9e9 commit eae1120
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/components/datagrid/body/data_grid_row_manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ describe('row manager', () => {
expect(row0.classList.contains('world')).toBe(true);
});

it('allows passing multiple classes', () => {
rerender({ ...mockArgs, rowClasses: { 0: 'hello world' } });
expect(getRow(0).classList.contains('hello')).toBe(true);
expect(getRow(0).classList.contains('world')).toBe(true);
});

it('adds/removes row classes correctly when gridStyle.rowClasses updates', () => {
rerender({ ...mockArgs, rowClasses: { 1: 'test' } });
const row0 = getRow(0);
Expand Down
2 changes: 1 addition & 1 deletion src/components/datagrid/body/data_grid_row_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const useRowManager = ({
rowElement.dataset.gridRowIndex = String(rowIndex); // Row index from data, not affected by sorting/pagination
rowElement.classList.add('euiDataGridRow');
if (rowClasses?.[rowIndex]) {
rowElement.classList.add(rowClasses[rowIndex]);
rowElement.classList.add(...rowClasses[rowIndex].split(' '));
}
rowElement.style.position = 'absolute';
rowElement.style.left = '0';
Expand Down
1 change: 1 addition & 0 deletions upcoming_changelogs/7301.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

- Fixed `EuiDataGrid`s with `gridStyle.stripes` sometimes showing buggy row striping after being sorted
- Fixed `EuiDataGrid`'s `gridStyle.rowClasses` API to not conflict with `gridStyle.stripes` if dynamically updated
- Fixed `EuiDataGrid`'s `gridStyle.rowClasses` API to support multiple space-separated classes

0 comments on commit eae1120

Please sign in to comment.