-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Duplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Current behavior 😯
When using the Arrow keys, the new active cell is not visible
https://master--material-ui-x.netlify.app/components/data-grid/#commercial-version
Expected behavior 🤔
When using the Arrow keys, the new active cell should be visible (scroll if necessary).
http://0.0.0.0:3001/components/data-grid/#commercial-version
with
diff --git a/packages/grid/x-data-grid/src/components/cell/GridCell.tsx b/packages/grid/x-data-grid/src/components/cell/GridCell.tsx
index 710c9577..bc983146 100644
--- a/packages/grid/x-data-grid/src/components/cell/GridCell.tsx
+++ b/packages/grid/x-data-grid/src/components/cell/GridCell.tsx
@@ -172,7 +172,7 @@ function GridCell(props: GridCellProps) {
const elementToFocus = focusableElement || cellRef.current;
if (doesSupportPreventScroll()) {
- elementToFocus.focus({ preventScroll: true });
+ elementToFocus.focus();
} else {
const scrollPosition = apiRef.current.getScrollPosition();
elementToFocus.focus();
We can also see it behave correctly on the first demo of https://www.ag-grid.com/.
Steps to reproduce 🕹
Steps:
- Open https://master--material-ui-x.netlify.app/components/data-grid/#commercial-version
- Follow the previous videos
Context 🔦
It's a regression introduced in #2999 with the objective to fix #2508. I have found this by looking into #4280 in more detail. cc @m4theushw
- First, in [DataGrid] Prevent scroll when selecting rows #2999 I have never seen a valid use case for using
preventScroll
so I'm always dubious when I see it. - Secondly, in [question] Issue with jumping x-grid starting from alpha.37 #2508 I would read the root problem as
.focus
is called when it shouldn't be called. Why is it called too often? Maybe because we useReact.useLayoutEffect
or because its dependencies change when they shouldn't.
I have tested it again #2508 (comment). It seems that the root problem in #2508 was solved closer to the root later on (I suspect in #3718). Therefore we could revert #2999 to fix this GitHub issue with no downsides.
Your environment 🌎
MUI X v5.7.0.
Order ID 💳 (optional)
No response