Et2Select: Not showing new freeEntry in select options immediately after adding it

This commit is contained in:
nathan 2023-11-22 16:03:01 -07:00
parent 7195ea09b2
commit 8f4c9cbb0a
2 changed files with 12 additions and 4 deletions

View File

@ -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}

View File

@ -195,7 +195,7 @@ export const Et2WithSearchMixin = dedupeMixin(<T extends Constructor<LitElement>
/* 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(<T extends Constructor<LitElement>
}
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(<T extends Constructor<LitElement>
this.__select_options.push(<SelectOption>{
value: text.trim(),
label: text.trim(),
class: "freeEntry"
class: "freeEntry",
isMatch: false
});
this.requestUpdate('select_options');
}