Skip to content

Commit 43442fe

Browse files
committed
[Autocomplete] Attempting a simpler "reset" of items
1 parent ea497d7 commit 43442fe

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Autocomplete/assets/src/controller.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ export default class extends Controller {
6363
}
6464

6565
connect() {
66+
this.initializeTomSelect();
67+
}
68+
69+
initializeTomSelect() {
6670
if (this.urlValue) {
6771
this.tomSelect = this.#createAutocompleteWithRemoteData(
6872
this.urlValue,
@@ -304,9 +308,8 @@ export default class extends Controller {
304308
private resetTomSelect(): void {
305309
if (this.tomSelect) {
306310
this.stopMutationObserver();
307-
this.tomSelect.clearOptions();
308-
this.tomSelect.settings.maxOptions = this.getMaxOptions();
309-
this.tomSelect.sync();
311+
this.tomSelect.destroy();
312+
this.initializeTomSelect();
310313
this.startMutationObserver();
311314
}
312315
}

0 commit comments

Comments
 (0)