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

Add a treeApi.setSelection method. #159

Merged
merged 2 commits into from
Jul 25, 2023
Merged

Add a treeApi.setSelection method. #159

merged 2 commits into from
Jul 25, 2023

Conversation

jameskerr
Copy link
Member

@jameskerr jameskerr commented Jul 24, 2023

Adds a new method to the TreeApi class called setSelection.

It allows for programatic control over the selection state. It is not concerned with changing focus or scrolling, only selection.

It accepts one argument. An object with the keys {ids, anchor, mostRecent}. These are the three pieces of state necessary for multiple selection.

Example:

useEffect(() => {
  tree.setSelection({
    ids: ["1", "2", "3"],
    anchor: "1", // or null
    mostRecent: "3" // or null
  })
}, [])

Fixes #156 #130 #145

@jameskerr
Copy link
Member Author

@adrianwysocki1993
@victorvianaom
@rkistinger
@liamdon
@lanesawyer

You've all recently submitted issues/PRs around the Tree's selection API. Would this PR solve your specific problems? Please provide feedback.

@adrianwysocki1993
Copy link

@adrianwysocki1993 @victorvianaom @rkistinger @liamdon @lanesawyer

You've all recently submitted issues/PRs around the Tree's selection API. Would this PR solve your specific problems? Please provide feedback.

It solves at least my problems. Thank you very much!

@lanesawyer
Copy link

Yeah, this looks great. Thank you for working on it!

@jameskerr jameskerr merged commit e49ac1d into main Jul 25, 2023
1 check passed
@jameskerr jameskerr deleted the set-selection branch July 25, 2023 16:55
@jameskerr
Copy link
Member Author

Version 3.2.0 is now out and contains this fix. Thanks for your contributions! https://github.com/brimdata/react-arborist/releases/tag/v3.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to select all children after clicking on a parent component?
3 participants