mui / mui-x

MUI X: Build complex and data-rich applications using a growing list of advanced React components, like the Data Grid, Date and Time Pickers, Charts, and more!
https://mui.com/x/
4.53k stars 1.32k forks source link

[data grid] Why does the cell lose focus on scroll with an Excel style top left corner click #12281

Open theobrasseurbentley opened 8 months ago

theobrasseurbentley commented 8 months ago

The problem in depth

Code sandbox: https://codesandbox.io/p/sandbox/mui-x-issue-template-forked-p7flgm?file=%2Fsrc%2FApp.tsx

  1. Open the code sandbox link
  2. Click the top left corner of the grid (the column header)
  3. Scroll down
  4. Scroll back up

Why does the cell lose focus on scroll with an Excel style top left corner click

Your environment

Browser: Chrome

System: OS: Windows 11 10.0.22631 Binaries: Node: 18.17.0 - C:\Program Files\nodejs\node.EXE npm: 9.6.7 - C:\Program Files\nodejs\npm.CMD pnpm: Not Found Browsers: Chrome: 122.0.6261.95 Edge: Chromium (122.0.2365.59) npmPackages: @emotion/react: 11.10.6 @emotion/styled: 11.10.6 @mui/base: 5.0.0-alpha.96 @mui/core-downloads-tracker: 5.12.2 @mui/icons-material: 5.11.16 @mui/material: ^5.10.15 => 5.12.2 @mui/private-theming: 5.12.0 @mui/styled-engine: 5.12.0 @mui/system: 5.12.1 @mui/types: 7.2.13 @mui/utils: 5.15.11 @mui/x-data-grid: 6.16.3 @mui/x-data-grid-generator: 6.19.5 @mui/x-data-grid-premium: ^6.16.3 => 6.16.3 @mui/x-data-grid-pro: 6.16.3 @mui/x-date-pickers: ^6.11.0 => 6.11.0 @mui/x-license-pro: ^6.0.0-beta.3 => 6.10.2 @mui/x-tree-view: ^6.0.0-alpha.1 => 6.0.0-alpha.1 @types/react: ^18.0.21 => 18.2.0 react: ^17.0.2 => 17.0.2 react-dom: ^17.0.2 => 17.0.2 typescript: ^4.8.4 => 4.9.5

Search keywords: focus cell excel style Order ID: 82553

michelengelen commented 8 months ago

Hey @theobrasseurbentley the link you provided does seem like its private. Could you make it public please?

theobrasseurbentley commented 8 months ago

Made public. The share link is:

https://codesandbox.io/p/sandbox/mui-x-issue-template-forked-p7flgm?file=%2Fsrc%2FApp.tsx

michelengelen commented 8 months ago

Ah, now I get what you mean. The cell loses focus because it is being unmounted due to our virtualization. You can turn that off, but it is not recommended, since it will reduce the grids performance. Disable Virtualization

@romgrk do we have a method of restoring focus when the cell gets back into view?

romgrk commented 8 months ago

That looks like a bug, focus isn't lost when it's set through keyboard shortcuts or the mouse.