Skip to content

Commit

Permalink
recompute grid height when rowCount changes
Browse files Browse the repository at this point in the history
  • Loading branch information
chandlerprall committed Dec 18, 2020
1 parent c4790bc commit 00ed696
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/datagrid/data_grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -687,13 +687,18 @@ export const EuiDataGrid: FunctionComponent<EuiDataGridProps> = (props) => {
// this triggers a double re-render when the grid is switched from constrained to unconstrained
// but in reality ... maybe don't do that?
const [gridHeight, setGridHeight] = useState(IS_JEST_ENVIRONMENT ? 500 : 0);
const pageSize = pagination?.pageSize;
useEffect(() => {
if (height == null) {
// if already 0 this update will be ignored
// if not already 0, this resets the height constraint so a new value can be observed
setGridHeight(0);
}
}, [height, pagination?.pageSize]);
}, [
height,
pageSize,
rowCount, // recompute height if the rowCount changes
]);

const [containerRef, _setContainerRef] = useState<HTMLDivElement | null>(
null
Expand Down

0 comments on commit 00ed696

Please sign in to comment.