Skip to content

Instantly share code, notes, and snippets.

@ConnectedReasoning
Created April 9, 2019 09:50
Show Gist options
  • Save ConnectedReasoning/e258793d10ea31d10a32db88dcd83977 to your computer and use it in GitHub Desktop.
Save ConnectedReasoning/e258793d10ea31d10a32db88dcd83977 to your computer and use it in GitHub Desktop.
handlers for autocomplete events
onAutocompleteFocus(){
this.setState({defaultValue:'@'});
this.setState({hideSuggestions:false});
}
onAutocompleteTextChange(context_value){
let suggestions = this.state.suggestions;
let newSuggestions = suggestions.filter(suggestion => {
return suggestion.startsWith(context_value);
});
this.setState({context_value});
this.setState({filteredSuggestions:newSuggestions});
if(context_value !== '@inbox'){
this.setState({hideSuggestions:false});
}
}
onAutocompleteSelect(context_value){
this.setState({context_value});
this.setState({hideSuggestions:true});
this.setState({defaultValue:context_value});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment