Skip to content

Indirectly selecting the starting item in a shift multiselect action results in an incorrect multiselection #336

Closed
@tonyketcham

Description

@tonyketcham

Describe the bug
When selecting the first item in a shift key held selection of multiple items, if the first item is selected via a ref or by changing the selectedItems view state on a ControlledTree, the starting state does not get overridden. Therefore, the previous item which was directly selected in the tree is incorrectly used as the start of the range.

To Reproduce

  1. Go to https://rct.lukasbach.com/docs/guides/refs
  2. Select "Banana" in the tree
  3. Click the ref button "Select items Apple and Orange"
  4. Hold down the shift key
  5. Select "Desserts" in the tree

Expected selection is:
[Apple, Orange, Lemon, Berries, Banana, Meals, Desserts]

Actual selection is:
[Banana, Meals, Desserts]

Expected behavior
Changes to the tree's selection state which originate outside of the tree component itself should overwrite the starting item in a multiselection range

Screenshots

Indirect.selection.multiselect.-.Example.1.mov
Indirect.selection.multiselect.-.Example.2.mov

Real-world case

When clicking on a layer in the visual canvas space, the selectedItems view state of the RCT layer tree is updated. Holding down shift to select the end item of a selection range in the tree then results in an incorrect multiselection:

In-context.example.mov

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions