Skip to content

Commit

Permalink
fix: arrow up/down highlighting moves off list
Browse files Browse the repository at this point in the history
When using keyboard arrow up/down to highlight items where there are
more suggestions than can be displayed by the maxResults parameter,
the highlight disappears but is still selecting an item, allowing
selection of a non-visible suggestion.

This limits keyboard highlighting to the lesser of the number of
suggestions or the value of maxResults.
  • Loading branch information
Birdstown committed Apr 15, 2020
1 parent 49f8cbd commit 53a640c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/auto-complete/auto-complete.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ export class AutoCompleteComponent implements AfterViewChecked, ControlValueAcce
this.showItemList();
}

const max = this.suggestions.length - 1;
const max = this.suggestions.length > this.maxResults ? this.maxResults - 1 : this.suggestions.length - 1;

if (direction < 0) {
if (this.focusedOption === -1 || this.focusedOption === max) {
Expand Down

0 comments on commit 53a640c

Please sign in to comment.