Fix Et2LinkEntry did not always show initial value

If link title was not already in cache, it might get left at ??.  It was not using passed title, and sometimes was not getting title from server fast enough.
This commit is contained in:
nathan 2022-06-02 10:18:46 -06:00
parent 2b85b0b920
commit d5055b9b95
2 changed files with 11 additions and 2 deletions

View File

@ -85,6 +85,10 @@ export class Et2LinkEntry extends Et2InputWidget(FormControlMixin(ValidateMixin(
const select = <Et2LinkSearch><unknown>document.createElement("et2-link-search");
if(typeof this._value !== "undefined")
{
if(this._value.title)
{
select.select_options = [{value: this._value.id, label: this._value.title}]
}
select.app = this._value.app;
select.value = this._value.id;
}

View File

@ -103,8 +103,13 @@ export class Et2LinkSearch extends Et2Select
{
option.label = title;
option.class = "";
// It's probably already been rendered
this.requestUpdate();
// It's probably already been rendered, find the item
let item = this.getItems().find(i => i.value === option.value);
if(item)
{
item.textContent = title;
item.classList.remove("loading");
}
});
}
}