From 4859eb27d92201ae1ca34b46375090a28d765649 Mon Sep 17 00:00:00 2001 From: joseph rosenthal Date: Mon, 24 Jun 2024 07:45:51 -0400 Subject: [PATCH] fixed handling of spinning icon when loading --- src/app/components/button/button.ts | 33 +---------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/src/app/components/button/button.ts b/src/app/components/button/button.ts index ffe988140a..a6b9d9a5c1 100755 --- a/src/app/components/button/button.ts +++ b/src/app/components/button/button.ts @@ -155,20 +155,6 @@ export class ButtonDirective implements AfterViewInit, OnDestroy { private _internalClasses: string[] = Object.values(INTERNAL_BUTTON_CLASSES); - spinnerIcon = ` - - - - - - - - - `; - constructor( public el: ElementRef, @Inject(DOCUMENT) private document: Document @@ -280,10 +266,6 @@ export class ButtonDirective implements AfterViewInit, OnDestroy { DomHandler.addMultipleClasses(iconElement, iconClass); } - if (!this.loadingIcon && this.loading) { - iconElement.innerHTML = this.spinnerIcon; - } - this.htmlElement.insertBefore(iconElement, this.htmlElement.firstChild); } } @@ -303,19 +285,6 @@ export class ButtonDirective implements AfterViewInit, OnDestroy { let iconElement = DomHandler.findSingle(this.htmlElement, '.p-button-icon'); let labelElement = DomHandler.findSingle(this.htmlElement, '.p-button-label'); - if (this.loading) { - if (!this.loadingIcon && iconElement) { - iconElement.innerHTML = this.spinnerIcon; - } else if (this.loadingIcon && iconElement) { - iconElement.className = `p-button-icon ${this.loadingIcon}`; - } - } else if (this.icon && iconElement) { - iconElement.className = `p-button-icon ${this.icon}`; - } else if (iconElement) { - iconElement.innerHTML = ''; - this.createIcon(); - } - if (iconElement) { if (this.iconPos) { iconElement.className = 'p-button-icon ' + (labelElement ? 'p-button-icon-' + this.iconPos : '') + ' ' + this.getIconClass(); @@ -328,7 +297,7 @@ export class ButtonDirective implements AfterViewInit, OnDestroy { } getIconClass() { - return this.loading ? 'p-button-loading-icon ' + (this.loadingIcon ? this.loadingIcon : 'p-icon') : this.icon || 'p-hidden'; + return this.loading ? 'p-button-loading-icon pi-spin ' + (this.loadingIcon ?? 'pi pi-spinner') : this.icon || 'p-hidden'; } ngOnDestroy() {