From 4367afaf27c85ba981d1718452d7cb20d7a17f52 Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 30 Nov 2023 11:56:14 -0700 Subject: [PATCH] Fix link search did not always show label for initial value --- api/js/etemplate/Et2Link/Et2LinkSearch.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api/js/etemplate/Et2Link/Et2LinkSearch.ts b/api/js/etemplate/Et2Link/Et2LinkSearch.ts index 09a6d26408..dca9818082 100644 --- a/api/js/etemplate/Et2Link/Et2LinkSearch.ts +++ b/api/js/etemplate/Et2Link/Et2LinkSearch.ts @@ -110,6 +110,7 @@ export class Et2LinkSearch extends Et2Select label: Et2Link.MISSING_TITLE, class: "loading" } + // Weird call instead of just unshift() to make sure to trigger setter this.select_options = Object.assign([option], this.__select_options); this.egw()?.link_title(this.app, option.value, true).then(title => @@ -117,10 +118,13 @@ export class Et2LinkSearch extends Et2Select option.label = title || Et2Link.MISSING_TITLE; option.class = ""; // It's probably already been rendered, find the item - let item = this.getAllOptions().find(i => i.value === option.value); + let item = this.select?.querySelector('[value="' + option.value + '"]'); if(item) { - item.textContent = title; + // Replace instead of changing the whole thing to preserve LitElement marker comments + item.innerHTML = item.innerHTML.replace(Et2Link.MISSING_TITLE, title); + this.select.requestUpdate("value"); + item.classList.remove("loading"); } else