From 28db39c18e08a4a29dc4c2fd444ab0a2e9e3037e Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 10 Jul 2024 13:13:55 -0600 Subject: [PATCH] Fix dropdown tree search Was constantly re-setting search term & dropdown --- api/js/etemplate/Et2Tree/Et2TreeDropdown.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/api/js/etemplate/Et2Tree/Et2TreeDropdown.ts b/api/js/etemplate/Et2Tree/Et2TreeDropdown.ts index 1708d903b9..c08c23fb02 100644 --- a/api/js/etemplate/Et2Tree/Et2TreeDropdown.ts +++ b/api/js/etemplate/Et2Tree/Et2TreeDropdown.ts @@ -225,7 +225,7 @@ export class Et2TreeDropdown extends SearchMixin & Et2InputWidg super.startSearch(); // Show the dropdown, that's where the results will go - this.show(); + this.open = true; // Hide the tree this.treeOrSearch = "search"; @@ -253,8 +253,8 @@ export class Et2TreeDropdown extends SearchMixin & Et2InputWidg if(this.multiple && typeof this.value !== "undefined") { - // Add in the new result(s) - (this.value).splice(this.value.length, 0, ...this.selectedResults.map(el => el.value)); + // Add in the new result(s), no duplicates + this.value = [...new Set([...this.value, ...this.selectedResults.map(el => el.value)])]; } else if(typeof this.value !== "undefined") { @@ -351,12 +351,10 @@ export class Et2TreeDropdown extends SearchMixin & Et2InputWidg this.hasFocus = true; // Should not be needed, but not firing the update this.requestUpdate("hasFocus"); - this.hide(); // Reset tags to not take focus this.setCurrentTag(null); - this._searchNode.setSelectionRange(this._searchNode.value.length, this._searchNode.value.length); } handleSearchKeyDown(event)