From d5055b9b95367d2ceb335d5a1acd63d86f4e16b5 Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 2 Jun 2022 10:18:46 -0600 Subject: [PATCH] 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. --- api/js/etemplate/Et2Link/Et2LinkEntry.ts | 4 ++++ api/js/etemplate/Et2Link/Et2LinkSearch.ts | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/api/js/etemplate/Et2Link/Et2LinkEntry.ts b/api/js/etemplate/Et2Link/Et2LinkEntry.ts index faa04c5935..09489d8b34 100644 --- a/api/js/etemplate/Et2Link/Et2LinkEntry.ts +++ b/api/js/etemplate/Et2Link/Et2LinkEntry.ts @@ -85,6 +85,10 @@ export class Et2LinkEntry extends Et2InputWidget(FormControlMixin(ValidateMixin( const select = 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; } diff --git a/api/js/etemplate/Et2Link/Et2LinkSearch.ts b/api/js/etemplate/Et2Link/Et2LinkSearch.ts index c8b48109ae..4296d7f1f6 100644 --- a/api/js/etemplate/Et2Link/Et2LinkSearch.ts +++ b/api/js/etemplate/Et2Link/Et2LinkSearch.ts @@ -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"); + } }); } }