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

When using <List> with single selection, can't deselect. #1003

Open
devblazer opened this issue Sep 23, 2019 · 0 comments
Open

When using <List> with single selection, can't deselect. #1003

devblazer opened this issue Sep 23, 2019 · 0 comments

Comments

@devblazer
Copy link

When using the List component with the single selection option and specifying a selectedIndex, you can't deselect the currently selected item.

I am currently using the List and ListItem in a form whereby my ListItem's have [key] properties with string hash based keys and my List component is being passed a selectedIndex that matches the currently selected 'hash'.

What I mean is that if I pass in a selectedIndex of [null, false, undefined, or any non-existent key], the component should fail to select something and there should be no selection as a result. Current behavior is that it simply ignores what you passed in and keeps the previously selected item selected, making it impossible to effectively deselect something.

Whats worse, is that if the reason your selectedIndex no longer matches any of the listItems keys is because the option that is currently selected got removed from the list of items (a perfectly valid scenario) then the List component will simply autoselect the next thing in the list, whether you want it to or not.

I believe this is because the List component is internally storing the current selection by 'array index' and when a new selected key is passed in, it tries to find a matching item and if it can't doesn't bother to update its internal state? I can't think of another explanation for this behavior.

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

No branches or pull requests

1 participant