downshift-js / downshift-js/downshift
Impossible to override input received on `onInputValueChange` after item selection
- Dominant language
- JavaScript
- Stars
- 12.3k
- Forks
- 936
- PR merge metrics
- No merged PRs in 30d
Description
- `downshift` version: 3.2.10
- `node` version: 10.15.3
- `yarn` version: 1.17.3
**Relevant code or config**
```javascript
const stateReducer = (state, changes) => {
switch (changes.type) {
case Downshift.stateChangeTypes.clickItem:
case Downshift.stateChangeTypes.keyDownEnter:
case Downshift.stateChangeTypes.controlledPropUpdatedSelectedItem:
return {
...changes,
inputValue: "input overriden"
};
default:
return changes;
}
};
```
**What you did**:
I tried to override via `stateRducer` the `inputValue` **after some item is selected**.
**What happened**:
The internal state gets updated, but then I receive from `onInputValueChange` the selected item string, instead of the `inputValue` in state.
**Reproduction repository**:
It is the basic autocomplete with minimum modifications and some explanations:
[Codesandbox](https://codesandbox.io/s/hardcore-goldwasser-2ugu4)
**Problem description**:
I can't get the `inputValue` that I have overridden via `stateReducer` from `onInputValueChange` after an item is selected. I always get the selected item string instead. This behaviour seems to be unexpected.
**Suggested solution**:
I have no suggestion yet! Can you confirm this is an unexpected behaviour?
Contributor guide
Assessment
This issue has not been assessed yet.