-
Notifications
You must be signed in to change notification settings - Fork 934
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
Added support for Shift + Click selection of rows #827
Conversation
This PR is most likely not compatible with #825, however, I could adjust it so that in the MUIDataTable.js file, when it was in the process of adding the adjacent rows, it would stop if it hit the maxSelectedRows threshold. |
This is a cool feature, thank you for working on this! I just reviewed and suggested a number of changes to #825, so how about we wait for that to be merged and integrated with yours before review? |
Sounds good, I’ll be unavailable next week but could make any adjustments tomorrow or the week after that. |
@patorjk The |
Sounds good, I’ll pull them and update this PR early next week! |
For trying this out, I added (but didn't commit) an isRowSelectable function that looked like this:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worked really well for me! I tested in multiple scenarios, including the isSelectable
you pointed out. I only have a few nitpicks, but otherwise looks great.
src/components/TableBody.js
Outdated
|
||
// Create a copy of the selectedRows object. This will be used and modified | ||
// below when we see if we can add adjacent rows. | ||
let selectedRows = JSON.parse(JSON.stringify(this.props.selectedRows)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be self-documenting and probably a bit less expensive to use lodash.clonedeep
, which is in the library, here instead.
src/components/TableBody.js
Outdated
let selectedRows = JSON.parse(JSON.stringify(this.props.selectedRows)); | ||
|
||
// Add the clicked on row to our copy of selectedRows (if it isn't already present). | ||
var clickedDataIndex = this.props.data[data.index].dataIndex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we can use let
here and below on line 129 since the variables don't need to leave their respective blocks.
An implementation of the feature suggested in #663
The UX for shift+click is modeled off of how GMail does it. For example, if you select/unselect row A and then hold shift and select/unselect row B:
If any filters are removed or columns resorted or selection headers toggled or data fetched (in the case of Server Side tables), between the selection of rows A and B, then there will be no special effect.