From 7ed9eef29d7953fd5c41e4e597190461deecb43d Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 13 Mar 2024 09:16:46 -0600 Subject: [PATCH] Resolve some Et2ButtonIcon issues from Shoelace upgrade - Avoid some 404s with egroupware icons trying to load from shoelace - Fix Shoelace icon not shown when button has an ID --- api/js/etemplate/Et2Button/Et2ButtonIcon.ts | 19 +++++++++++++++---- api/js/etemplate/Styles/shoelace.ts | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/api/js/etemplate/Et2Button/Et2ButtonIcon.ts b/api/js/etemplate/Et2Button/Et2ButtonIcon.ts index 81b48293b1..e942563797 100644 --- a/api/js/etemplate/Et2Button/Et2ButtonIcon.ts +++ b/api/js/etemplate/Et2Button/Et2ButtonIcon.ts @@ -43,11 +43,22 @@ export class Et2ButtonIcon extends ButtonMixin(Et2InputWidget(SlIconButton)) { this.src = this.egw().image(new_image); } - if(new_image && !this.src) + + // For some reason setting it directly does not show the image + this.updateComplete.then(() => { - // For some reason setting it directly does not show the image - this.updateComplete.then(() => this.name = new_image); - } + const icon = this.shadowRoot.querySelector('sl-icon'); + icon.id = ""; + if(new_image && !this.src) + { + icon.src = ""; + icon.name = new_image; + } + else + { + icon.name = ""; + } + }); } get image() diff --git a/api/js/etemplate/Styles/shoelace.ts b/api/js/etemplate/Styles/shoelace.ts index 8d82d5d6e7..c8ee2130f4 100644 --- a/api/js/etemplate/Styles/shoelace.ts +++ b/api/js/etemplate/Styles/shoelace.ts @@ -15,7 +15,7 @@ import {egw} from "../../jsapi/egw_global"; registerIconLibrary('default', { resolver: name => { - return typeof egw !== "undefined" ? `${egw.webserverUrl || ""}/node_modules/@shoelace-style/shoelace/dist/assets/icons/${name}.svg` : '' + return typeof egw !== "undefined" ? (egw.image(name) ?? `${egw.webserverUrl || ""}/node_modules/@shoelace-style/shoelace/dist/assets/icons/${name}.svg`) : '' }, });