From 413ac5ba6ad0cf38127dc9ee302405f23021c6d7 Mon Sep 17 00:00:00 2001 From: Egor Boaghi Date: Sun, 5 Jan 2025 13:16:05 +0200 Subject: [PATCH 1/2] Add in button directive possibility to store the icon in case it was already created, allowing icon restoration after loading is complete. --- packages/primeng/src/button/button.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/primeng/src/button/button.ts b/packages/primeng/src/button/button.ts index 3ded2413b52..a917aab8f47 100755 --- a/packages/primeng/src/button/button.ts +++ b/packages/primeng/src/button/button.ts @@ -358,6 +358,11 @@ export class ButtonDirective extends BaseComponent implements AfterViewInit, OnD createIcon() { const created = findSingle(this.htmlElement, '.p-button-icon'); + // store icon to allow its restoration after loading is finished. + if (!this.icon && created) { + const iconClasses: string[] = created.className.split(' '); + this.icon = iconClasses.filter((className: string) => !className.startsWith('p-')).join(' '); + } if (!created && (this.icon || this.loading)) { let iconElement = this.document.createElement('span'); iconElement.className = 'p-button-icon'; From f94031d219d2ef149c5bcbb7647f09303ce4a45e Mon Sep 17 00:00:00 2001 From: Egor Boaghi Date: Sun, 5 Jan 2025 13:16:58 +0200 Subject: [PATCH 2/2] Add in button directive possibility to label to fix loading broken styles in case the icon is present. --- packages/primeng/src/button/button.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/primeng/src/button/button.ts b/packages/primeng/src/button/button.ts index a917aab8f47..7ad90d366c2 100755 --- a/packages/primeng/src/button/button.ts +++ b/packages/primeng/src/button/button.ts @@ -343,6 +343,10 @@ export class ButtonDirective extends BaseComponent implements AfterViewInit, OnD createLabel() { const created = findSingle(this.htmlElement, '.p-button-label'); + // label presence decides some styles for loading + if (!this.label && created) { + this.label = created.innerHTML; + } if (!created && this.label) { let labelElement = this.document.createElement('span'); if (this.icon && !this.label) {