question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting the selectedItem to '' does not clear the inputValue

See original GitHub issue
  • downshift version: 1.16.0
  • node version:
  • npm (or yarn) version:

What you did: I have a component that lists several items using several “Downshift-enriched” inputs. At the end of the list there is an empty Downshift-enriched input for adding a new item to the list. As such the components are semi-controlled, in the sense that the selectedItem property is set by the parent component.

What happened: If I select a new item using the last input component I would expect that a new empty input component appears after the last one. However, it appears a new input component where the input value is the one selected before.

Reproduction repository: https://codesandbox.io/s/k5px1z0075 Select a fruit (apple for example) in the only input that appears and see that two components have the same fruit (instead of being one selected and the other one empty).

Problem description: Maybe setting to null or '' the selectedItem prop does not correctly clear the internal state.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
kentcdoddscommented, Nov 6, 2017

If you would be willing, I would appreciate a pull request that demonstrates this approach in source, tests, and a new example. Could you do that? Thanks so much for iterating with me on this!

0reactions
davvidbakercommented, Dec 5, 2017

Just ran into this same problem, and happy to find you guys already figured it out! This is what I ❤️ about open-source. Thanks for all your hard work!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Input field (using downshift) is clearing the entered data when ...
The input is empty because itemToString={item => (item ? item.first_name : '')} in Downshift component. The value in second condition (else ...
Read more >
Issue with sap.m.input - Value not present at initialization
Hi Clark,. first, I think that the behaviour you describe is a side effect, that the previously selected item is not in suggested...
Read more >
useComboBoxState – React Stately
Handles building a collection of items from props and manages the option selection state of the combo box. In addition, it tracks the...
Read more >
Select | Quasar Framework
The QSelect Vue component has two types of selection - single or multiple. This component opens up a menu for the selection list...
Read more >
useCombobox - Downshift
selectedItem, State value with the item that is selected. ... Since clearing the input by Escape key is also considered an element change,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found