You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to implement a customer request to keep the input's field value intact after selecting. So I tried doing this in the stateReducer:
const{ changes, type }=actionAndChanges;switch(type){casestateChangeTypes.InputKeyDownEnter:
casestateChangeTypes.ItemClick:
return{
...changes,inputValue: state.inputValue,// Keep the previous input value.};default:
returnchanges;}
That didn't work so after printing the state and changes I found out that it's already having both selectedItem and inputValue set. In my understanding that should happen in the reducer, so the state should not have those values set, and changes should. After returning changes, the new state should be updated.
What happened:
Suggested solution:
I'm not sure but it seems like the state was already update prior the reducer function was called.
The text was updated successfully, but these errors were encountered:
You will find a stateReducer example there for useCombobox, if that's what you are using. Just replace the uppercase thing from there with state.inputValue and it should be good to go. Thanks!
downshift
version: 7.6.0node
version: 20npm
(oryarn
) version: 1.9What you did:
I was trying to implement a customer request to keep the input's field value intact after selecting. So I tried doing this in the
stateReducer
:That didn't work so after printing the
state
andchanges
I found out that it's already having bothselectedItem
andinputValue
set. In my understanding that should happen in the reducer, so thestate
should not have those values set, andchanges
should. After returning changes, the new state should be updated.What happened:
Suggested solution:
I'm not sure but it seems like the state was already update prior the reducer function was called.
The text was updated successfully, but these errors were encountered: