Add null check

This commit is contained in:
Rob Jack Stewart 2024-02-20 18:49:07 +00:00
parent 37ab270c89
commit e974a09144
1 changed files with 5 additions and 5 deletions

View File

@ -161,12 +161,12 @@ class MovieSearchInput extends Component {
return;
}
// If a suggestion is highlighted, go to that movie
// otherwise search for a new movie
if (highlightedSuggestionIndex) {
this.goToMovie(suggestions[highlightedSuggestionIndex]);
} else {
// If no suggestion is highlighted, search for a new movie
// otherwise go to the suggested movie
if (highlightedSuggestionIndex == null) {
this.props.onGoToAddNewMovie(value);
} else {
this.goToMovie(suggestions[highlightedSuggestionIndex]);
}
this._autosuggest.input.blur();