-
Notifications
You must be signed in to change notification settings - Fork 933
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: Reset downshift state when inputValue changes #664
Comments
Thank you for the improvement request @bkilrain . I'd be happy to see this solved in our library so every user can benefit from it. Are you up for a Pull Request? :) I won't lie, I'd be happy to see this change asap in Downshift, as I need it in Stardust as well. But I'd be happier if the change will be done by anyone else than me, so we can grow Downshift community more. |
Yep - I'm happy to take this on. To be clear, we just want to reset Downshift state when |
I don't think we need to do all of that. As I understand, the issue is to reset only the highlightedIndex to the defaultHighlightedIndex each time the input value changes. Am I correct? Resetting the whole state will probably mean other state stuff reset which we may not want to reset, like the selected item. |
Ok - fair enough. |
Hey there - I've completed the fix but I'm getting this error when I run the Also, I'll submit from my work github account. Thanks! |
downshift
version: 3.1.12node
version: 8.11.1npm
(oryarn
) version: 5.6.0Relevant code or config
What you did:
I'm using Downshift to render the dropdown for an autocomplete component. The
defaultHighlightedIndex
is set to0
so that there is always a 'highlighted' item in the dropdown.What happened:
If I hover an item lower in the list (index 4 or 5), however, and type to filter out possible items to a number less than the highlightedIndex, the
highlightedIndex
state does not update to ensure a highlighted item is still rendered in the dropdown.Steps to Reproduce:
Code Sandbox Link
Suggested solution:
Right now, I'm calling
reset()
on every input change to get around this. As far as changes to the library, perhaps we could compare the highlightedIndex with the itemCount to make sure a highlighted item is being rendered at all times? Or add the inputChange event to cases where downshift's state is reset. Can anyone think of a usecase where they don't want downshift state to reset on inputChange?The text was updated successfully, but these errors were encountered: