Skip to content

Commit

Permalink
[EuiDataGrid] Fix "Grid row classes" docs example (elastic#7549)
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Mar 5, 2024
1 parent 42e20e7 commit 4408b42
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
4 changes: 4 additions & 0 deletions changelogs/upcoming/7549.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**Bug fixes**

- Fixed an `EuiDataGrid` bug with `gridStyle.rowClasses`, where custom consumer classes that began with `euiDataGridRow` would not be correctly removed/reapplied
- Fixed a visual `EuiDataGrid` bug where `EuiCheckbox`es within control columns were not vertically centered within single height rows
30 changes: 14 additions & 16 deletions src-docs/src/views/datagrid/styling/row_classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const SelectionRowCell = ({ rowIndex }) => {
const [selectedRows, updateSelectedRows] = useContext(SelectionContext);
const isChecked = selectedRows.has(rowIndex);
return (
<div>
<>
<EuiCheckbox
id={`${rowIndex}`}
aria-label={`Select row ${rowIndex}, ${data[rowIndex].name}`}
Expand All @@ -103,7 +103,7 @@ const SelectionRowCell = ({ rowIndex }) => {
}
}}
/>
</div>
</>
);
};

Expand Down Expand Up @@ -153,20 +153,18 @@ export default () => {

return (
<SelectionContext.Provider value={rowSelection}>
<div>
<EuiDataGrid
aria-label="Top EUI contributors"
columns={columns}
columnVisibility={{ visibleColumns, setVisibleColumns }}
rowCount={data.length}
renderCellValue={({ rowIndex, columnId }) => data[rowIndex][columnId]}
leadingControlColumns={leadingControlColumns}
toolbarVisibility={{
additionalControls: <SelectionButton />,
}}
gridStyle={{ rowClasses, rowHover: 'none' }}
/>
</div>
<EuiDataGrid
aria-label="Top EUI contributors"
columns={columns}
columnVisibility={{ visibleColumns, setVisibleColumns }}
rowCount={data.length}
renderCellValue={({ rowIndex, columnId }) => data[rowIndex][columnId]}
leadingControlColumns={leadingControlColumns}
toolbarVisibility={{
additionalControls: <SelectionButton />,
}}
gridStyle={{ rowClasses, rowHover: 'none' }}
/>
</SelectionContext.Provider>
);
};
4 changes: 4 additions & 0 deletions src/components/datagrid/_data_grid_data_row.scss
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@
height: auto;
display: flex;
align-items: center;

&.euiDataGridRowCell__content--defaultHeight {
height: 100%;
}
}

// Positioning for cell actions & the cell expansion popover
Expand Down
4 changes: 3 additions & 1 deletion src/components/datagrid/body/data_grid_row_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ export const useRowManager = ({
if (rowClasses) {
rowIdToElements.current.forEach((rowElement, rowIndex) => {
const euiClasses = Array.from(rowElement.classList)
.filter((className) => className.startsWith('euiDataGridRow'))
.filter((className) =>
['euiDataGridRow', 'euiDataGridRow--striped'].includes(className)
)
.join(' ');

if (rowClasses[rowIndex]) {
Expand Down

0 comments on commit 4408b42

Please sign in to comment.