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

[Feature request] ListData selection management convenience methods #7666

Open
Faithfinder opened this issue Jan 24, 2025 · 4 comments
Open
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@Faithfinder
Copy link

Faithfinder commented Jan 24, 2025

Provide a general summary of the feature here

I'd like equivalents of add and remove methods for selection.

😯 Current Behavior

Manual implementation like

let nextSelected = new Set(list.selectedKeys);
if (list.selectedKeys === "all") {
  nextSelected = new Set(initialItems.map((metric) => metric.id));
}
nextSelected.delete(metric.id);
list.setSelectedKeys(nextSelected);
@Faithfinder Faithfinder changed the title ListData selection management convenience methods [Feature request] ListData selection management convenience methods Jan 24, 2025
@snowystinger
Copy link
Member

Just checking, you mean for useListData?

That hook is really just to get people started, you are more than welcome to use your own hook to manage data. You could probably wrap our hook in your own to supply this functionality.

I'll still check if it's something we'd like to add.

@Faithfinder
Copy link
Author

Faithfinder commented Jan 29, 2025

I've found it quite convenient to use it as is in scenarios where I need to do a lot to arrays of data.

Writing your own is always an option, but I bet this isn't much effort to expose. Without looking at source, you must already have these methods internally on the SelectionManager (or somewhere else, for integration with RAC ListBox and friends)

@snowystinger
Copy link
Member

We discussed this today, and we'd like to add it, though we want to workshop the names of the functions a bit more.

Would you like to create a PR?

@Faithfinder
Copy link
Author

Hmm, maybe. I don't have a lot of time for open source, but this doesn't look like a lot of work, maybe I can find a couple of hours somewhere =P

@snowystinger snowystinger added enhancement New feature or request good first issue Good for newcomers labels Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants