fix: keep prior selection when shift-clicking after ctrl-click#679
fix: keep prior selection when shift-clicking after ctrl-click#679spike-rabbit wants to merge 1 commit intomainfrom
Conversation
07e1c77 to
aec6650
Compare
There was a problem hiding this comment.
Code Review
This pull request fixes a regression where shift-clicking to select a range would clear previously selected rows. The changes ensure that the current selection is preserved when calculating the new range and add a guard for the previous selection index. A performance optimization was suggested for the selection utility to use a Set for membership checks instead of Array.includes() to avoid quadratic time complexity during large selections.
3936c96 to
dc44ba0
Compare
There was a problem hiding this comment.
Pull request overview
Fixes multi-row selection behavior so that shift-click range selection preserves any prior ctrl/meta selections (issue #582), and adds coverage for the regression.
Changes:
- Update shift-click selection to extend the current selection instead of replacing it with an empty selection.
- Add de-duplication when adding a shift-click range to the selection.
- Add unit tests reproducing ctrl-click + shift-click behavior and a “first click is shift” edge case.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| projects/ngx-datatable/src/lib/utils/selection.ts | Adds de-dupe logic when selecting ranges. |
| projects/ngx-datatable/src/lib/components/body/body.component.ts | Preserves existing selection when shift-selecting, guarded by prevIndex. |
| projects/ngx-datatable/src/lib/components/body/body.component.spec.ts | Adds regression tests for ctrl+shift multi-selection behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dc44ba0 to
17e4802
Compare
What kind of change does this PR introduce? (check one with "x")
What is the current behavior? (You can also link to an open issue here)
Closes #582. Shift-clicking after a Ctrl-click discards previously selected rows because the range selection replaces the selection with
[].What is the new behavior?
Shift-click extends the existing selection with the range from the last clicked row, preserving prior Ctrl-selections. Duplicates are skipped.
Does this PR introduce a breaking change? (check one with "x")
Other information:
Added a unit test in
body.component.spec.tscovering the issue's repro steps.