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

ListViewSelectionController.isItemSelected can't be used if the ListView isn't visible #14

Closed
Hixie opened this issue Aug 1, 2021 · 0 comments · Fixed by #15
Closed

Comments

@Hixie
Copy link

Hixie commented Aug 1, 2021

I have a list of items that can be selected or not. It affects many aspects of the app. There's a ListView that's used to configure that list of items, so I use a ListViewSelectionController as the source of truth. Unfortunately that ListView isn't always on screen, so sometimes it's not attached, and ListViewSelectionController.isItemSelected asserts that it is attached. So I can't use the ListViewSelectionController as the source of truth.

Side note: it would be great if ListViewSelectionController had an affordance to enumerate the selected items. Currently I have to just loop over the items one by one querying if they're selected, and that seems expensive given how the list is backed.

tvolkert added a commit that referenced this issue Aug 2, 2021
They served to enforce that the caller can't set the selection
to an out-of-bounds index based on an attached list view,
but that's notnecessary at all -- the caller just sets selected
ranges, and if those ranges are outside the bounds of the actual
list content, there's no inherent harm in that; it's the caller's
business.

The only non-assert usage of attach/detach was the `selectAll()`
API method, but that API's not needed either, since the caller
knows their data model and can just set the desired range.

Fixes #14
tvolkert added a commit that referenced this issue Aug 2, 2021
tvolkert added a commit that referenced this issue Aug 2, 2021
They served to enforce that the caller can't set the selection
to an out-of-bounds index based on an attached list view,
but that's notnecessary at all -- the caller just sets selected
ranges, and if those ranges are outside the bounds of the actual
list content, there's no inherent harm in that; it's the caller's
business.

The only non-assert usage of attach/detach was the `selectAll()`
API method, but that API's not needed either, since the caller
knows their data model and can just set the desired range.

Fixes #14
tvolkert added a commit that referenced this issue Aug 2, 2021
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 a pull request may close this issue.

1 participant