Skip to content

Conversation

@Jszigeti
Copy link
Contributor

Problem

While investigating #11010, I discovered that the Shift+Click deselection behavior actually exists in the Datagrid, but was only partially working in some cases.

  • Basic range selection worked fine
  • But in specific scenarios (e.g. after “Select All”, or when alternating select/deselect actions), Shift+Click didn’t correctly update the selection state.

This led to UX inconsistencies compared to common list-selection patterns in tools like Gmail, Google Sheets, or file explorers.


Solution

  • Fixed the range toggle logic in DataTableBase.tsx:
    • Detects whether the clicked item is already selected (instead of relying on event.target.checked)
    • Always updates lastSelected.current, even when deselecting
    • Ensures consistent Shift+Select and Shift+Deselect behavior

Added unit tests in DataTable.spec.tsx
Added E2E tests in list.cy.js

Both confirm correct behavior for:

  • Alternating Shift+Select and Shift+Deselect
  • Shift+Deselect after “Select All”

How To Test

  1. Go to any list view with bulk selection enabled.
  2. Select a first item, then Shift+Click another to select a range.
  3. Shift+Click one of the selected items again → all items in that range should now be deselected.
  4. Run tests:
    • make test
    • make e2e
      All DataTable and E2E tests should pass.

Additional Checks

  • The PR targets master for a bugfix
  • The PR includes unit tests (DataTable.spec.tsx)
  • The PR includes E2E tests (list.cy.js)
  • No documentation change required (behavior aligns with existing feature)
  • No story update required (visual behavior unchanged)

Notes

  • Fixes partial inconsistencies mentioned in #11010.
  • No breaking changes.
  • Improves UX consistency with standard multi-selection behavior.
  • A couple of unrelated tests occasionally fail on master (confirmed unrelated to this change).

I'm happy to adjust anything if needed 👍

@djhi
Copy link
Collaborator

djhi commented Oct 30, 2025

Sweet! Thanks!

@djhi djhi added this to the 5.12.3 milestone Oct 30, 2025
@djhi djhi merged commit 2c575c8 into marmelab:master Oct 30, 2025
21 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants