diff --git a/CHANGELOG.md b/CHANGELOG.md index 10e2e2d9b7a..1fc3e3648ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ - Added possibility to hide "Rows per page" select in `EuiDataGrid` ([#3700](https://github.com/elastic/eui/pull/3700)) - Updated lodash to `v4.17.19` ([#3764](https://github.com/elastic/eui/pull/3764)) - Added `returnKey` glyph to `EuiIcon` ([#3783](https://github.com/elastic/eui/pull/3783)) + +**Bug fixes** + +- Fixed bug in `EuiDataGrid` not calculating the width correctly ([#3789](https://github.com/elastic/eui/pull/3789)) ## [`27.2.0`](https://github.com/elastic/eui/tree/v27.2.0) diff --git a/src/components/datagrid/data_grid.tsx b/src/components/datagrid/data_grid.tsx index 8b4b229ccbe..aae3cca8702 100644 --- a/src/components/datagrid/data_grid.tsx +++ b/src/components/datagrid/data_grid.tsx @@ -310,6 +310,9 @@ function useDefaultColumnWidth( const widthToFill = gridWidth - claimedWidth; const unsizedColumnCount = columns.length - columnsWithWidths.length; + if (unsizedColumnCount === 0) { + return 100; + } return Math.max(widthToFill / unsizedColumnCount, 100); }, [gridWidth, columns, leadingControlColumns, trailingControlColumns]);