From bfa2477f5b4d1ff4b2125a48ff8890a2889e5eb1 Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 18 Aug 2022 16:22:39 -0600 Subject: [PATCH] Fix description label did not handle %s This is the "preferred" way of handling such things with LitElement (in render), over the way Et2Widget has to change the DOM due to extended widgets. --- api/js/etemplate/Et2Description/Et2Description.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/api/js/etemplate/Et2Description/Et2Description.ts b/api/js/etemplate/Et2Description/Et2Description.ts index 05a53a3dac..6725ea6034 100644 --- a/api/js/etemplate/Et2Description/Et2Description.ts +++ b/api/js/etemplate/Et2Description/Et2Description.ts @@ -11,6 +11,7 @@ import {Et2Widget} from "../Et2Widget/Et2Widget"; import {css, html, LitElement, render} from "@lion/core"; import {et2_IDetachedDOM} from "../et2_core_interfaces"; import {activateLinks} from "../ActivateLinksDirective"; +import {et2_csvSplit} from "../et2_core_common"; export class Et2Description extends Et2Widget(LitElement) implements et2_IDetachedDOM { @@ -174,9 +175,21 @@ export class Et2Description extends Et2Widget(LitElement) implements et2_IDetach render() { + let label = this.label; + let after; + if(label) + { + // Split the label at the "%s" + let parts = et2_csvSplit(label, 2, "%s"); + if(parts.length > 1) + { + after = html``; + label = parts[0]; + } + } // Turn off IDE reformatting, or it will add an extra line break into the template // @formatter:off - return html`${this.label}`; + return html`${label}${after}`; // @formatter:on }