Skip to content

Commit

Permalink
[EuiDataGrid] Fix timeout clean-up when component unmounts (#7534)
Browse files Browse the repository at this point in the history
Co-authored-by: Marco Antonio Ghiani <[email protected]>
  • Loading branch information
tonyghiani and Marco Antonio Ghiani authored Feb 20, 2024
1 parent 47ab766 commit d74601b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelogs/upcoming/7534.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Bug fixes**

- Fixed `EuiDataGrid` component to clean up timer from side effect on unmount
4 changes: 3 additions & 1 deletion src/components/datagrid/utils/grid_height_width.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,14 @@ export const useVirtualizeContainerWidth = (

useEffect(() => {
// wait for layout to settle, then measure virtualize container
setTimeout(() => {
const timerId = setTimeout(() => {
if (virtualizeContainer?.clientWidth) {
const containerWidth = virtualizeContainer.clientWidth;
setVirtualizeContainerWidth(containerWidth);
}
}, 100);

return () => clearTimeout(timerId);
}, [pageSize, virtualizeContainer]);

// Use clientWidth of the virtualization container to take scroll bar into account
Expand Down

0 comments on commit d74601b

Please sign in to comment.