Skip to content

Commit

Permalink
[DataGrid] Fix bug in suspense (#12553)
Browse files Browse the repository at this point in the history
  • Loading branch information
romgrk committed Mar 25, 2024
1 parent 48677e4 commit 6551530
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,9 @@ function GridColumnHeaderItem(props: GridColumnHeaderItemProps) {
const focusableElement = headerCellRef.current!.querySelector<HTMLElement>('[tabindex="0"]');
const elementToFocus = focusableElement || headerCellRef.current;
elementToFocus?.focus();
apiRef.current.columnHeadersContainerRef!.current!.scrollLeft = 0;
if (apiRef.current.columnHeadersContainerRef?.current) {
apiRef.current.columnHeadersContainerRef.current.scrollLeft = 0;
}
}
}, [apiRef, hasFocus]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ const GridGenericColumnHeaderItem = React.forwardRef(function GridGenericColumnH
const focusableElement = headerCellRef.current!.querySelector<HTMLElement>('[tabindex="0"]');
const elementToFocus = focusableElement || headerCellRef.current;
elementToFocus?.focus();
apiRef.current.columnHeadersContainerRef!.current!.scrollLeft = 0;
if (apiRef.current.columnHeadersContainerRef?.current) {
apiRef.current.columnHeadersContainerRef.current.scrollLeft = 0;
}
}
}, [apiRef, hasFocus]);

Expand Down

0 comments on commit 6551530

Please sign in to comment.