From 09e0a970ac6ff6cc489c1c1c1521c2295795c9e1 Mon Sep 17 00:00:00 2001 From: Xon <635541+Xon@users.noreply.github.com> Date: Wed, 4 Sep 2024 19:36:11 +0800 Subject: [PATCH] Add flag to setChoices on if to reset the search flag (default true) --- src/scripts/choices.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/scripts/choices.ts b/src/scripts/choices.ts index 2005cecd..9a859e07 100644 --- a/src/scripts/choices.ts +++ b/src/scripts/choices.ts @@ -663,8 +663,9 @@ class Choices { | (InputChoice | InputGroup)[] | ((instance: Choices) => (InputChoice | InputGroup)[] | Promise<(InputChoice | InputGroup)[]>) = [], value: string | null = 'value', - label = 'label', - replaceChoices = false, + label: string = 'label', + replaceChoices: boolean = false, + clearSearchFlag: boolean = true, ): this | Promise { if (!this.initialisedOK) { this._warnChoicesInitFailed('setChoices'); @@ -724,6 +725,9 @@ class Choices { this.containerOuter.removeLoadingState(); this._store.withTxn(() => { + if (clearSearchFlag) { + this._isSearching = false; + } const isDefaultValue = value === 'value'; const isDefaultLabel = label === 'label';