From 70be19cdfb619bc1ee96b1ea3bb482e223ccbaf0 Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 25 Sep 2023 10:16:32 -0600 Subject: [PATCH] Et2Select: Fix change event did not fire when free entry was added --- api/js/etemplate/Et2Select/SearchMixin.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/js/etemplate/Et2Select/SearchMixin.ts b/api/js/etemplate/Et2Select/SearchMixin.ts index 327ebcef45..a444d854b7 100644 --- a/api/js/etemplate/Et2Select/SearchMixin.ts +++ b/api/js/etemplate/Et2Select/SearchMixin.ts @@ -464,7 +464,7 @@ export const Et2WithSearchMixin = dedupeMixin( protected _noResultsTemplate() { - if(this._total_result_count !== 0) + if(this._total_result_count !== 0 || !this._searchInputNode?.value) { return nothing; } @@ -1294,7 +1294,7 @@ export const Et2WithSearchMixin = dedupeMixin( return false; } // Make sure not to double-add - if(!this.querySelector("[value='" + text.replace(/'/g, "\\\'") + "']") && !this.__select_options.find(o => o.value == text)) + if(!this.querySelector("[value='" + text.replace(/'/g, "\\\'") + "']") && !this.select_options.find(o => o.value == text)) { this.__select_options.push({ value: text.trim(), @@ -1315,6 +1315,7 @@ export const Et2WithSearchMixin = dedupeMixin( { this.value = text; } + this.dispatchEvent(new Event("change", {bubbles: true})); // If we were overlapping edit inputbox with the value display, reset if(!this.readonly && this._activeControls?.classList.contains("novalue"))