Clear dropdown input on open

main
Jake Dexheimer 7 years ago
parent ba1d550cd3
commit 4bfde22b48

@ -35,10 +35,21 @@ class Dropdown extends Component {
changes.type === Downshift.stateChangeTypes.keyDownArrowDown) changes.type === Downshift.stateChangeTypes.keyDownArrowDown)
) { ) {
inputValue = itemsToShow[changes.highlightedIndex].name inputValue = itemsToShow[changes.highlightedIndex].name
this.props.onChange(itemsToShow[changes.highlightedIndex])
} }
if (clearUserInput) { if (changes.hasOwnProperty('isOpen')) {
this.userInputtedValue = '' this.userInputtedValue = ''
// clear on open
if (changes.isOpen) {
inputValue = ''
}
// set on close
if (changes.isOpen === false && !inputValue) {
inputValue = this.props.selected.name
}
} }
return { inputValue, itemsToShow } return { inputValue, itemsToShow }

Loading…
Cancel
Save