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

After selecting an option, typehead doesn't work until blur and refocus

Open apaleslimghost opened this issue 8 years ago • 11 comments

apaleslimghost avatar Nov 27 '16 12:11 apaleslimghost

Same issue on my end.

This fixed it for me, i added this to my onOptionSelect callback:

this.refs.typeahead.setEntryText(''); this.refs.typeahead.setState({ showResults: true })

zikphil avatar Dec 04 '16 21:12 zikphil

I fixed it by doing a manual blur/focus on the input, which is horrible 😕

apaleslimghost avatar Dec 04 '16 21:12 apaleslimghost

Same issue - fixed thanks to @zikphil

NickBrooks avatar Jan 31 '17 07:01 NickBrooks

You can also use an onchange event and the typeahead as a ref similar to @zikphil

if (this.typeahead.state.showResults !== true) {
	this.typeahead.setState({ showResults: true });
}

shawn-simon-developer avatar Apr 21 '17 20:04 shawn-simon-developer

does anyone know if there is a fix to this? i have tried @zikphil's method and it didnt work...

Richard-Thompson avatar Dec 15 '17 07:12 Richard-Thompson

@Richard-Thompson have you tried my workaround?

apaleslimghost avatar Dec 15 '17 10:12 apaleslimghost

I'm not using the tokeniser version just the other standard typeahead version, so Im not sure how to integrate that into my code base. Here is my code for the typeahead:

        <Typeahead
            defaultValue='o'
            ref='typeahead'
            options={this.props.playlists}
            filterOption='songTitle'
            maxVisible={10}
            displayOption={(option) => {
              return option.songTitle;
            }}
            onOptionSelected={(option)=> {
                this.refs.typeahead.setEntryText('');
              browserHistory.push(`/playlist/${option.playlistTitle}`);
            }}
            customClasses={{
              input: "topcoat-text-input",
              results: "results-container",
              hover: "result-active"
            }} 
            className={`${this.props.screenSize} form-control mr-sm-2`}
        />

Richard-Thompson avatar Dec 15 '17 11:12 Richard-Thompson

in onOptionSelected, adding this.refs.typeahead.refs.entry.blur() ; this.refs.typeahead.refs.entry.focus() should work

apaleslimghost avatar Dec 15 '17 12:12 apaleslimghost

all im getting is screen shot 2017-12-15 at 13 02 53

maybe the package has changed this this fix was stated?

Richard-Thompson avatar Dec 15 '17 13:12 Richard-Thompson

ah, sorry, typo. it should be this.refs.typeahead.refs.entry.blur() (same for focus as well)

apaleslimghost avatar Dec 15 '17 13:12 apaleslimghost

Thanks, this has worked, I was so close to using .entry wasn't too sure. Anyway thanks for the help!

Richard-Thompson avatar Dec 15 '17 13:12 Richard-Thompson