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 multi-select for list #4477

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

dweymouth
Copy link
Contributor

@dweymouth dweymouth commented Dec 22, 2023

Description:

  • Adds new enum widget.SelectionMode (values: SelectionSingle, SelectionMultiple, SelectionNone)
    • This only effects the tap/key handling, not the programmatic APIs
  • Adds tap/key handling for multi-select, respecting SelectionMode setting
  • Adds a few new APIs related to multi-select
    • SelectOnly(ListItemID)
    • SelectAll()
    • SetSelection([]ListItemID)
  • The list.Select API now adds to the selection (which is what the documentation said), rather than replacing it

TODO/ Concerns:

  • tests
  • This uses a slice of IDs to keep track of selection, and creates a new selection slice on any unselect operation. This makes thread-safety fairly easy, but comes with some performance tradeoffs:
    • Repeatedly unselecting items causes a lot of memory churn (UnselectAll is implemented efficiently)
    • setupListItem is now O(n) in number of selected items. This is a potential concern
    • Notifying onSelected/onUnselected callbacks is O(n^2) in operations that select multiple IDs at once (SelectAll, SetSelection)

Fixes #2575 (for list)

Checklist:

  • Tests included.
  • Lint and formatter run with no errors.
  • Tests all pass.

Where applicable:

  • Public APIs match existing style and have Since: line.

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.

None yet

2 participants