Skip to content

Commit

Permalink
Fixes an issue preventing the first item from being selected when the…
Browse files Browse the repository at this point in the history
… 'down' key is pressed and the 'disableAutoSelect' option is set to true.
  • Loading branch information
kraaden committed Jul 21, 2023
1 parent 04cecdd commit 96fded6
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion autocomplete.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion autocomplete.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion autocomplete.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion autocomplete.min.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ export default function autocomplete<T extends AutocompleteItem>(settings: Autoc
}

function updateSelectedSuggestion(index: number) {
if (index > -1 && items.length > 0) {
if (items.length > 0) {
unselectSuggestion(index);
selectSuggestion(items.indexOf(selected!));
updateScroll();
Expand All @@ -467,7 +467,7 @@ export default function autocomplete<T extends AutocompleteItem>(settings: Autoc

function selectSuggestion(index: number) {
var element = doc.getElementById(container.id + "_" + index);
if(element) {
if (element) {
element.classList.add('selected');
element.setAttribute('aria-selected', 'true');
input.setAttribute('aria-activedescendant', element.id);
Expand All @@ -476,7 +476,7 @@ export default function autocomplete<T extends AutocompleteItem>(settings: Autoc

function unselectSuggestion(index: number) {
var element = doc.getElementById(container.id + "_" + index);
if(element) {
if (element) {
element.classList.remove('selected');
element.removeAttribute('aria-selected');
input.removeAttribute('aria-activedescendant');
Expand Down

0 comments on commit 96fded6

Please sign in to comment.