Skip to content

Commit

Permalink
feat: add loading state class to input
Browse files Browse the repository at this point in the history
From denis-taran#105 but stop loading if no result
  • Loading branch information
prigaux committed Jan 9, 2024
1 parent 0c7602d commit d348aed
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,9 @@ export default function autocomplete<T extends AutocompleteItem>(settings: Autoc
function startFetch(inputText: string, trigger: EventTrigger, cursorPos: number) {
if (destroyed) return;
const savedFetchCounter = ++fetchCounter;
input.classList.add('ac-loading');
settings.fetch(inputText, function (elements: T[] | false): void {
input.classList.remove('ac-loading');
if (fetchCounter === savedFetchCounter && elements) {
items = elements;
inputValue = inputText;
Expand Down

0 comments on commit d348aed

Please sign in to comment.