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

Enable range selection of checkboxes #4742

Merged
merged 2 commits into from Dec 8, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 22 additions & 8 deletions jsapp/js/components/submissions/table.es6
Expand Up @@ -1228,17 +1228,31 @@ export class DataTable extends React.Component {
* @param {boolean} isChecked
*/
bulkUpdateChange(sid, isChecked) {
const selectedRows = this.state.selectedRows;
const {selectedRows, lastChecked} = this.state;

if (isChecked) {
selectedRows[sid] = true;
const updatedSelectedRows = {...selectedRows, [sid]: true};

// Handles range selection of checkboxes if the shift key is pressed
if (window.event?.shiftKey && lastChecked) {
const [start, end] = [lastChecked, sid].map(Number);
for (let i = Math.min(start, end); i <= Math.max(start, end); i++) {
updatedSelectedRows[i] = true;
}
}
this.setState({
selectedRows: updatedSelectedRows,
lastChecked: isChecked ? sid : null,
selectAll: false,
});
} else {
delete selectedRows[sid];
const {[sid]: _, ...updatedSelectedRows} = selectedRows;
this.setState({
selectedRows: updatedSelectedRows,
lastChecked: null,
selectAll: false,
});
}

this.setState({
selectedRows: selectedRows,
selectAll: false,
});
}

/**
Expand Down