Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[data grid] onCellSelectionModelChange not triggered when ctrl+dragging to select additional cells #14184

Closed
skjalghodneland opened this issue Aug 13, 2024 · 9 comments · Fixed by #14199
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Cell Selection Related to the cell selection feature support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/

Comments

@skjalghodneland
Copy link

skjalghodneland commented Aug 13, 2024

Steps to reproduce

Link to live example: https://codesandbox.io/s/zealous-allen-jnpptr?file=/src/Demo.tsx
(This can also be replicated in the official example from mui docs. This sandbox is a slightly changed version of the one from mui docs that outputs the count of selected cells to make it easier to spot the issue)

Steps:

  1. Enable cellSelection
    (optional) Add some logic (for example logging) in onCellSelectionModelChange to see the issue
  2. Select a singular cell, or a group of cells by clicking and dragging across multiple cells. You will see this get updated in your onCellSelectionModelChange.
  3. Hold ctrl and select another group of cells by clicking and dragging across multiple cells
    As you will see from onCellSelectionModelChange the selected cells will not be updated when you do step 3. If you proceed to select a singular additional cell by holding ctrl and clicking on a single cell the selected cells will update and contain all the cells you selected in step 2 and 3.

Selecting one cell:
image

Selecting multiple additional cells by ctrl+dragging:
image
Note that the count has not updated.

Selecting one singular additional cell with ctrl+click, now the count updates
image

Current behavior

onCellSelectionModelChange does not trigger when releasing the mouse after ctrl+drag selecting more cells after initial selection.

Expected behavior

onCellSelectionModelChange should trigger when releasing the mouse after ctrl+drag selecting more cells, similar to how it does on the initial selection and when ctrl+clicking a singular cell.

Context

We wish to allow our users to select multiple cells and perform actions on these cells, and with this bug this process is not natural. In other software this UX is fairly standard, and the bug that the onCellSelectionModelChange does not trigger when using the grid in this way causes a disconnect between what is visually represented to the user as selected cells and what our code is aware of.

Your environment

I'm not able to run this command on the sandbox, but the problem exists there as well where all the versions are latest. Below is from the software where we use this. Tested using Chrome.

npx @mui/envinfo

  System:
    OS: Windows 11 10.0.22631
  Binaries:
    Node: 20.12.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.5.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: Not Found
  Browsers:
    Chrome: Not Found
    Edge: Chromium (127.0.2651.74)
  npmPackages:
    @emotion/react: ^11.11.4 => 11.11.4
    @emotion/styled: ^11.11.5 => 11.11.5
    @mui/base:  5.0.0-beta.40
    @mui/core-downloads-tracker:  5.15.15
    @mui/material: ^5.15.15 => 5.15.15
    @mui/private-theming:  5.15.14
    @mui/styled-engine:  5.15.14
    @mui/system:  5.15.15
    @mui/types:  7.2.14
    @mui/utils:  5.15.14
    @mui/x-data-grid:  7.3.1
    @mui/x-data-grid-premium: ^7.3.1 => 7.3.1
    @mui/x-data-grid-pro:  7.3.1
    @mui/x-license: ^7.2.0 => 7.2.0
    @types/react: ^18.2.79 => 18.2.79
    react: ^18.2.0 => 18.2.0
    react-dom: ^18.2.0 => 18.2.0
    typescript: ^5.4.2 => 5.4.4

Search keywords: cellselection multiple cells onCellSelectionModelChange not triggering selectionmodel not updating
Order ID: 89129

@skjalghodneland skjalghodneland added bug 🐛 Something doesn't work status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 13, 2024
@github-actions github-actions bot added component: data grid This is the name of the generic UI component, not the React module! support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/ labels Aug 13, 2024
@arminmeh arminmeh changed the title onCellSelectionModelChange not triggered when ctrl+dragging to select additional cells [DataGridPremium] onCellSelectionModelChange not triggered when ctrl+dragging to select additional cells Aug 13, 2024
@michelengelen michelengelen changed the title [DataGridPremium] onCellSelectionModelChange not triggered when ctrl+dragging to select additional cells [data grid] onCellSelectionModelChange not triggered when ctrl+dragging to select additional cells Aug 13, 2024
@arminmeh
Copy link
Contributor

Hi @skjalghodneland
Thanks for reporting this.

I have made a PR to fix this issue

@arminmeh arminmeh added feature: Cell Selection Related to the cell selection feature and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 14, 2024
@github-project-automation github-project-automation bot moved this to 🆕 Needs refinement in MUI X Data Grid Aug 14, 2024
@arminmeh arminmeh moved this from 🆕 Needs refinement to 👀 In review in MUI X Data Grid Aug 14, 2024
@skjalghodneland
Copy link
Author

Thank you @arminmeh this seems to work perfectly!
How long do you think it will take for this to get merged to production? We need to decide if we want to push cell selection with this bug to our production code or wait for the fixed version to be available.

@arminmeh
Copy link
Contributor

arminmeh commented Aug 15, 2024

@skjalghodneland I have asked more people for a review
data grid is released every week (mostly on Thursday)

@skjalghodneland
Copy link
Author

No chance this makes it in time for this week's release then since the PR has still not been approved? @arminmeh

@arminmeh
Copy link
Contributor

@skjalghodneland the PR has been approved and should be merged once the build passes. This means that the fix will be released this week.

@skjalghodneland
Copy link
Author

Thank you so much @arminmeh! Really appreciate the fast turnaround time on this, its very reassuring to know that reporting bugs here leads to a swift response from you and the rest of the mui-x team. Hope you have a great rest of your week!

Copy link

⚠️ This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

@skjalghodneland: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

@efotin
Copy link

efotin commented Sep 14, 2024

@skjalghodneland the PR has been approved and should be merged once the build passes. This means that the fix will be released this week.

Can it be merged to V6 premium?

@arminmeh arminmeh moved this from 👀 In review to ✅ Done in MUI X Data Grid Sep 16, 2024
@arminmeh
Copy link
Contributor

@efotin
I will soon make a PR to fix the same issue for v6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Cell Selection Related to the cell selection feature support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/
Projects
Status: Done
3 participants