Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
apaleslimghost opened this issue Nov 27, 2016 · 11 comments

Comments

@apaleslimghost
Copy link

@zikphil
Copy link

zikphil commented Dec 4, 2016

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 })

@apaleslimghost
Copy link
Author

apaleslimghost commented Dec 4, 2016

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

@NickBrooks
Copy link

NickBrooks commented Jan 31, 2017

Same issue - fixed thanks to @zikphil

@shawn-simon-developer
Copy link

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 });
}

@Richard-Thompson
Copy link

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

@apaleslimghost
Copy link
Author

@Richard-Thompson have you tried my workaround?

@Richard-Thompson
Copy link

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`}
        />

@apaleslimghost
Copy link
Author

apaleslimghost commented Dec 15, 2017

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

@Richard-Thompson
Copy link

Richard-Thompson commented Dec 15, 2017

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

maybe the package has changed this this fix was stated?

@apaleslimghost
Copy link
Author

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

@Richard-Thompson
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants