Skip to content

Commit

Permalink
fix edge case bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Bargs committed Oct 16, 2018
1 parent 779d360 commit 91e83d1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/ui/public/query_bar/components/query_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,10 @@ export class QueryBar extends Component<Props, State> {
public decrementIndex = (currentIndex: number) => {
const previousIndex = currentIndex - 1;
if (previousIndex < 0) {
this.setState({ index: 0 });
this.setState({ index: this.state.suggestions.length - 1 });
} else {
this.setState({ index: previousIndex });
}
this.setState({ index: previousIndex });
};

public getSuggestions = async () => {
Expand Down Expand Up @@ -338,7 +339,7 @@ export class QueryBar extends Component<Props, State> {
if (isSuggestionsVisible && this.state.suggestions[index]) {
this.selectSuggestion(this.state.suggestions[index]);
} else {
this.onSubmit(event.preventDefault);
this.onSubmit(() => event.preventDefault());
}
break;
case KEY_CODES.ESC:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const SuggestionComponent: SFC<Props> = props => {
// Description currently always comes from us and we escape any potential user input
// at the time we're generating the description text
// eslint-disable-next-line react/no-danger
// @ts-ignore
dangerouslySetInnerHTML={{ __html: props.suggestion.description }}
/>
</div>
Expand Down

0 comments on commit 91e83d1

Please sign in to comment.