downshift version: 1.0.1node version: 6.9.1npmyarn) version: 0.24.5Relevant code or config
Demo on Codesandbox
What you did:
Howdy @kentcdodds and company! I'm trying to get my formerly react-autocompletely demo working with downshift.
The Autocompletely version (demo here) that I made used the Autocompletely wrapper's onChange event handler, which exposed a number of different properties.
I am trying to port that demo over to the current Downshift implementation.
What happened:
It seems that now the only Downshift state that is exposed in the wrapper's onChange handler is the item/input value (ln 153 on the demo repo, posted below), and not any actions that can handle the Downshift instance's state.
When testing my demo, you can type a city name and click a desired entry, and everything works fine. However, when you select an entry via keyboard control, the value can be saved to a component's state and the input's value cleared, but if you start to type a city name and blur the input, the last keyboard-entered value is set as the inputValue; it's my understanding that this is because the Downshift wrapper does not expose a clearSelection function, so even if you have a ref that can handle a clearing of an input's value (as I do in my demo), the Downshift state still renders its internal inputValue in the input that calls getInputProps.
Reproduction repository:
Problem description:
Keyboard-selected entries from Downshift's menu cause any input calling getInputProps to render with a value of inputValue if the input is blurred after typing (and even fully erasing) any text, but only immediately after a keyboard-selected entry has been selected.
Suggested solution:
Expose clearSelection to the Downshift wrapper's onClick handler so that external controls and methods can clear the wrapper's internal state.
PS: is my issue related to this change on #1 ?
So here's one way you could do it. But I'm thinking that instead of allState we can just give you all the same stuff you get in your function as child callback. I'm going to do that. Wont be a breaking change and would be pretty handy :+1:
Could you give this a review? https://github.com/paypal/downshift/pull/156
Sorry, been busy. That looks great! Will update my example accordingly.
I just found my way here now because I needed this. Awesome!
Most helpful comment
I just found my way here now because I needed this. Awesome!