Skip to content

Commit

Permalink
fix(primeng/p-button): not working loadingIcon property, update loa…
Browse files Browse the repository at this point in the history
…dingdoc example

Fixes primefaces#13098.
  • Loading branch information
volvachev committed Jun 16, 2023
1 parent 4f69e5a commit 0c8cdd6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/app/components/button/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export class ButtonDirective implements AfterViewInit, OnDestroy {
<ng-container *ngTemplateOutlet="contentTemplate"></ng-container>
<ng-container *ngIf="loading">
<ng-container *ngIf="!loadingIconTemplate">
<span *ngIf="loadingIcon" [class]="'p-button-loading-icon' + icon" [ngClass]="iconClass()"></span>
<span *ngIf="loadingIcon" [class]="'p-button-loading-icon ' + loadingIcon" [ngClass]="iconClass()"></span>
<SpinnerIcon *ngIf="!loadingIcon" [styleClass]="iconClass() + ' p-button-loading-icon'" [spin]="true" />
</ng-container>
<span *ngIf="loadingIconTemplate" class="p-button-loading-icon">
Expand Down
11 changes: 9 additions & 2 deletions src/app/showcase/doc/button/loadingdoc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input } from '@angular/core';
import { ChangeDetectorRef, Component, Input } from '@angular/core';
import { Code } from '../../domain/code';

@Component({
Expand All @@ -9,6 +9,8 @@ import { Code } from '../../domain/code';
</app-docsectiontext>
<div class="card flex justify-content-center">
<p-button label="Submit" [loading]="loading" (click)="load()"></p-button>
<p-button label="Loading custom icon" [loading]="loading" loadingIcon="pi pi-bell" (click)="load()"></p-button>
</div>
<app-code [code]="code" selector="button-loading-demo"></app-code>
</section>`
Expand All @@ -20,21 +22,26 @@ export class LoadingDoc {

loading: boolean = false;

constructor(private readonly cdr: ChangeDetectorRef) {}

load() {
this.loading = true;

setTimeout(() => {
this.loading = false;
this.cdr.markForCheck();
}, 2000);
}

code: Code = {
basic: `
<p-button label="Submit" [loading]="loading" (click)="load()"></p-button>`,
<p-button label="Submit" [loading]="loading" (click)="load()"></p-button>
<p-button label="Loading custom icon" [loading]="loading" loadingIcon="pi pi-bell" (click)="load()"></p-button>`,

html: `
<div class="card flex justify-content-center">
<p-button label="Submit" [loading]="loading" (click)="load()"></p-button>
<p-button label="Loading custom icon" [loading]="loading" loadingIcon="pi pi-bell" (click)="load()"></p-button>
</div>`,

typescript: `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class AppDocSectionNavComponent implements OnInit, OnDestroy {
label && label.parentElement.scrollIntoView({ block: 'start', behavior: 'smooth' });
}
}

isActiveChildId(isFirst: boolean, activeId: string, childId: string, parentId: string): boolean {
if (isFirst) {
return this.getActiveChildId(activeId, parentId);
Expand Down

0 comments on commit 0c8cdd6

Please sign in to comment.