react-typeahead icon indicating copy to clipboard operation
react-typeahead copied to clipboard

Click outside must close suggestions.

Open divined opened this issue 7 years ago • 3 comments

Click outside must close suggestions.

How to?

divined avatar Oct 13 '17 16:10 divined

After any page updates suggestions are opens again (((

Why not focused element show suggestions? Please add rules to showResults:

  1. entryValue in_array searchResults and searchResults.length == 1 > hide
  2. isFocused == false > hide

divined avatar Oct 19 '17 10:10 divined

On my project I use this concept:

  • create isSuggestionOpen state, and set it to false by default
  • while user focus on input, set that state to true (via onFocus props)
  • if user click outside input, set that state to false (via onBlur props)
  • in customClasses.results props, I add this class (just for example): Typeahead__container Typeahead__container--${this.state.isSuggestionOpen ? 'isOpen' : 'isHide'} and control it via visibility, opacity, or display. It's your option.
  • it works for me. May help you :)

faultables avatar Nov 03 '17 17:11 faultables

simiply, we can set showResults to false on _onBlur Function

this.setState({isFocused: false, showResults: false}, function () {

instead of just,

this.setState({isFocused: false }, function () {

it works with me :smile:

abdallahokasha avatar Apr 25 '18 17:04 abdallahokasha