diff --git a/api/js/etemplate/Et2Select/Et2Select.ts b/api/js/etemplate/Et2Select/Et2Select.ts index 502b1dbc49..b03f8724d4 100644 --- a/api/js/etemplate/Et2Select/Et2Select.ts +++ b/api/js/etemplate/Et2Select/Et2Select.ts @@ -672,7 +672,7 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect) { return html`${repeat(this.select_options // Filter out empty values if we have empty label to avoid duplicates - .filter(o => this.emptyLabel ? o.value !== '' : o), o => o.value, this._groupTemplate.bind(this)) + .filter(o => this.emptyLabel ? o.value !== '' : o), (o : SelectOption) => o.value, this._groupTemplate.bind(this)) }`; } @@ -705,7 +705,7 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect) title="${!option.title || this.noLang ? option.title : this.egw().lang(option.title)}" class=${classMap({ "match": this.searchEnabled && (option.isMatch || false), - "no-match": this.searchEnabled && !(option.isMatch || false), + "no-match": this.searchEnabled && option.isMatch == false, ...classes })} .option=${option} diff --git a/api/js/etemplate/Et2Select/SearchMixin.ts b/api/js/etemplate/Et2Select/SearchMixin.ts index dad44ac01d..9e1bd31e37 100644 --- a/api/js/etemplate/Et2Select/SearchMixin.ts +++ b/api/js/etemplate/Et2Select/SearchMixin.ts @@ -195,7 +195,7 @@ export const Et2WithSearchMixin = dedupeMixin( /* Hide options that do not match current search text */ - [searching] .no-match { + :host([search]) sl-option.no-match { display: none; } /* Different cursor for editable tags */ @@ -1155,6 +1155,13 @@ export const Et2WithSearchMixin = dedupeMixin( } this.select_options.map(clear_flag); this.requestUpdate("select_options"); + + // Rendering options using repeat() means we need to explicitly update the nodes since they + // don't always get re-rendered + for(const option of this.select.querySelectorAll(".no-match")) + { + option.classList.remove("no-match", "match"); + } } /** @@ -1393,7 +1400,8 @@ export const Et2WithSearchMixin = dedupeMixin( this.__select_options.push({ value: text.trim(), label: text.trim(), - class: "freeEntry" + class: "freeEntry", + isMatch: false }); this.requestUpdate('select_options'); }