Skip to content

Commit 19ea8ed

Browse files
committed
fix: keep autocomplete loading state when one of multiple searches is canceled
1 parent b61550b commit 19ea8ed

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/autocomplete/src/Autocomplete.svelte

+4-4
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
204204
let element: HTMLDivElement;
205205
let inputContainer: HTMLDivElement;
206-
let loading = false;
206+
let loading = 0;
207207
let error = false;
208208
let focused = false;
209209
let listAccessor: SMUIListAccessor;
@@ -216,7 +216,7 @@
216216
$: menuOpen =
217217
focused &&
218218
(text !== '' || showMenuWithNoInput) &&
219-
(loading ||
219+
(loading > 0 ||
220220
(!combobox && !(matches.length === 1 && matches[0] === value)) ||
221221
(combobox &&
222222
!!matches.length &&
@@ -288,7 +288,7 @@
288288
}
289289
290290
async function performSearch() {
291-
loading = true;
291+
loading++;
292292
error = false;
293293
try {
294294
const searchResult = await search(text);
@@ -306,7 +306,7 @@
306306
} catch (e: any) {
307307
error = true;
308308
}
309-
loading = false;
309+
loading--;
310310
}
311311
312312
function handleListAccessor(event: CustomEvent<SMUIListAccessor>) {

0 commit comments

Comments
 (0)