fix(pageFilters): clear shift-click anchor on empty selection#115472
Open
priscilawebdev wants to merge 1 commit into
Open
fix(pageFilters): clear shift-click anchor on empty selection#115472priscilawebdev wants to merge 1 commit into
priscilawebdev wants to merge 1 commit into
Conversation
After deselecting every option via shift+click, the anchor lingered on the last clicked item. The next shift+click would then range-extend from that ghost anchor instead of acting as a fresh single click. Clear lastSelected when the staged selection becomes empty so the next shift+click falls through the existing null-anchor branch.
Contributor
📊 Type Coverage Diff✅ No new type safety issues introduced. Coverage: 93.51% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The shift-click range selection in
useStagedCompactSelectkept its anchor (lastSelected) pointing at the last clicked option even after the staged selection became empty. The next shift-click would then range-extend from that ghost anchor.Repro (environment selector on the traces explorer)
With environments
[A, B, C, D, E]:A— selects[A], anchor =AE— range-selects[A, B, C, D, E], anchor =EE, D, C, B, Aone by one — incrementally deselects the range; selection ends at[], but anchor lingers atAC— expected[C], actual[A, B, C]Fix
In the
'toggle'and'toggle range'reducer cases, clearlastSelectedtonullwhenever the resultingstagedValueis empty. The next shift-click then falls through the existinglastSelected === nullbranch, which already treats it as a regular single click (the same path used when the menu first opens).A stricter check (treat the anchor as invalid whenever it's not in the current selection) was attempted but broke the existing
'deselects range when shift-clicking already selected item'test, which relies on a ctrl-clicked-off anchor still being usable for a range-deselect.Added a unit test that walks through the exact repro above.