Fix dropdown tree search

Was constantly re-setting search term & dropdown
This commit is contained in:
nathan 2024-07-10 13:13:55 -06:00
parent 0cb09698a1
commit 28db39c18e

View File

@ -225,7 +225,7 @@ export class Et2TreeDropdown extends SearchMixin<Constructor<any> & Et2InputWidg
super.startSearch(); super.startSearch();
// Show the dropdown, that's where the results will go // Show the dropdown, that's where the results will go
this.show(); this.open = true;
// Hide the tree // Hide the tree
this.treeOrSearch = "search"; this.treeOrSearch = "search";
@ -253,8 +253,8 @@ export class Et2TreeDropdown extends SearchMixin<Constructor<any> & Et2InputWidg
if(this.multiple && typeof this.value !== "undefined") if(this.multiple && typeof this.value !== "undefined")
{ {
// Add in the new result(s) // Add in the new result(s), no duplicates
(<string[]>this.value).splice(this.value.length, 0, ...this.selectedResults.map(el => el.value)); this.value = [...new Set([...this.value, ...this.selectedResults.map(el => el.value)])];
} }
else if(typeof this.value !== "undefined") else if(typeof this.value !== "undefined")
{ {
@ -351,12 +351,10 @@ export class Et2TreeDropdown extends SearchMixin<Constructor<any> & Et2InputWidg
this.hasFocus = true; this.hasFocus = true;
// Should not be needed, but not firing the update // Should not be needed, but not firing the update
this.requestUpdate("hasFocus"); this.requestUpdate("hasFocus");
this.hide();
// Reset tags to not take focus // Reset tags to not take focus
this.setCurrentTag(null); this.setCurrentTag(null);
this._searchNode.setSelectionRange(this._searchNode.value.length, this._searchNode.value.length);
} }
handleSearchKeyDown(event) handleSearchKeyDown(event)