Skip to content

Commit

Permalink
fix: keep autocomplete loading state when one of multiple searches is…
Browse files Browse the repository at this point in the history
… canceled
  • Loading branch information
hperrin committed May 19, 2024
1 parent b61550b commit 19ea8ed
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/autocomplete/src/Autocomplete.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
let element: HTMLDivElement;
let inputContainer: HTMLDivElement;
let loading = false;
let loading = 0;
let error = false;
let focused = false;
let listAccessor: SMUIListAccessor;
Expand All @@ -216,7 +216,7 @@
$: menuOpen =
focused &&
(text !== '' || showMenuWithNoInput) &&
(loading ||
(loading > 0 ||
(!combobox && !(matches.length === 1 && matches[0] === value)) ||
(combobox &&
!!matches.length &&
Expand Down Expand Up @@ -288,7 +288,7 @@
}
async function performSearch() {
loading = true;
loading++;
error = false;
try {
const searchResult = await search(text);
Expand All @@ -306,7 +306,7 @@
} catch (e: any) {
error = true;
}
loading = false;
loading--;
}
function handleListAccessor(event: CustomEvent<SMUIListAccessor>) {
Expand Down

0 comments on commit 19ea8ed

Please sign in to comment.