Skip to content

Commit

Permalink
fixed bug in datagrid calcuate width (#3789)
Browse files Browse the repository at this point in the history
* fixed bug in datagrid calcuate width

* adding changelog

* Improving changelog

* fixed minimum column width of EuiDataGrid to 100

Co-authored-by: miukimiu <[email protected]>
  • Loading branch information
Tocknicsu and elizabetdev authored Jul 27, 2020
1 parent fa901d4 commit 915790b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions src/components/datagrid/data_grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down

0 comments on commit 915790b

Please sign in to comment.