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

[DataGrid] Allow to select range of rows with shift key #2456

Merged
merged 61 commits into from
Oct 5, 2021

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Aug 26, 2021

  • Handle keyboard selection expansion / reduction with Shift
  • Handle click selection expansion / reduction with Shift
  • New method apiRef.current.selectRowRange to handle in a single place the keyboard and mouse range selection behavior

Closes #1858

Preview: https://deploy-preview-2456--material-ui-x.netlify.app/components/data-grid/selection

@flaviendelangle flaviendelangle added the component: data grid This is the name of the generic UI component, not the React module! label Aug 26, 2021
@flaviendelangle flaviendelangle self-assigned this Aug 26, 2021
@m4theushw
Copy link
Member

There's this expandSelection method that I don't know why it exists, it seems to be related to some Shift + click functionality that it would be implemented. The blame doesn't point to any PR. You can either remove it or reuse it.

https://github.com/mui-org/material-ui-x/blob/b00994865cc5956ec765f85a36103fd62258f6bb/packages/grid/_modules_/grid/hooks/features/keyboard/useGridKeyboard.ts#L19

@flaviendelangle
Copy link
Member Author

flaviendelangle commented Aug 26, 2021

This method seems buggy
It was supposed to handle the selection with the keyboard, my PR was focusing more on the click selection, but I'll fix this one too 👍

@flaviendelangle flaviendelangle added the on hold There is a blocker, we need to wait label Sep 2, 2021
@flaviendelangle
Copy link
Member Author

@mui-org/x can we merge this PR once the release is done ?

I didn't approve it yet because the Shift + click was not working with checkboxSelection. Do you plan to work on #2456 (review)?

I was convinced I fixed this one...my bad if it is not. I will take a look

@flaviendelangle
Copy link
Member Author

@m4theushw #2456 (review) is done 👍

docs/src/pages/components/data-grid/selection/selection.md Outdated Show resolved Hide resolved
if (selectedRowsIds.length > 0) {
const selectedRowsIndex = selectedRowsIds.map((id) => apiRef.current.getRowIndex(id));
const startRowIndex = Number(rowEl.getAttribute('data-rowindex'));
const startId = apiRef.current.getRowIdFromRowIndex(startRowIndex);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Selecting filtered rows with the keyboard is not working. The ID has to come from the selector, not from apiRef.current.getRowIdFromRowIndex.

@flaviendelangle flaviendelangle merged commit f64dfdf into mui:next Oct 5, 2021
@flaviendelangle flaviendelangle deleted the selection-range branch October 5, 2021 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DataGrid] Extend selection with Shift + click
2 participants