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/
3.92k stars 1.19k forks source link

[data grid] Shift + Arrow Keys Not Selecting Correct Rows After Independent Row Selection #13631

Open peichenc24 opened 1 week ago

peichenc24 commented 1 week ago

Steps to reproduce

Link to live example: https://mui.com/x/react-data-grid/row-selection/#multiple-row-selection

Steps:

  1. select multiple independent rows using ctrl + click (make sure at least one row is not selected in between)
  2. start using shift + arrow to select a range of rows
  3. some rows should be selected, but it is not

Current behavior

https://github.com/mui/mui-x/assets/41612241/b60b8cf8-02f5-49b2-8757-a13a14553640

Expected behavior

Continued from above example; There are two possible expected behaviors, depend on the design.

  1. All rows should be selected like below image
  2. Original selected rows should be deselected image

Personally, I prefer 1, I think it make more sense for user want to select more rows using shift + arrowkeys

Context

No response

Your environment

Env from sandbox System: OS: Linux 6.1 Debian GNU/Linux 12 (bookworm) 12 (bookworm) Binaries: Node: 20.12.0 - /usr/local/bin/node npm: 10.5.0 - /usr/local/bin/npm pnpm: 8.15.6 - /usr/local/share/npm-global/bin/pnpm Browsers: Chrome: Not Found npmPackages: @emotion/react: latest => 11.11.4 @emotion/styled: latest => 11.11.5 @mui/base: 5.0.0-beta.40 @mui/core-downloads-tracker: 5.15.20 @mui/icons-material: next => 6.0.0-alpha.12 @mui/material: latest => 5.15.20 @mui/private-theming: 5.15.20 @mui/styled-engine: 5.15.14 @mui/system: 5.15.20 @mui/types: 7.2.14 @mui/utils: 5.15.20 @mui/x-data-grid: 7.7.1 @mui/x-data-grid-generator: latest => 7.7.1 @mui/x-data-grid-premium: 7.7.1 @mui/x-data-grid-pro: latest => 7.7.1 @mui/x-license: 7.7.1 @types/react: latest => 18.3.3 react: latest => 18.3.1 react-dom: latest => 18.3.1 typescript: latest => 5.5.2

Search keywords: shift arrow keys selection Order ID: 76852

michelengelen commented 1 week ago

Hey @peichenc24 ... thanks for raising this. It is indeed a bit misleading and I would expect option 1 to be happening as well.

I'll add this to the board. Again thanks for raising this. Highly appreciated! 🙇🏼

peichenc24 commented 1 week ago

Hey @michelengelen , I also found that selecting all rows using Ctrl + a works (a is small letter), but if my keyboard Caps Lock is on, Ctrl + A (Capital letter) does not work. Is this a expected behavior?

Sorry for the inconvenience. Looking forward to your reply. Thanks!