Skip to content

Commit

Permalink
fix(primeng/p-button): spinner style not working propely
Browse files Browse the repository at this point in the history
  • Loading branch information
volvachev committed Jun 12, 2023
1 parent 229bb94 commit a483588
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/app/components/button/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export class ButtonDirective implements AfterViewInit, OnDestroy {
<ng-container *ngIf="loading">
<ng-container *ngIf="!loadingIconTemplate">
<span *ngIf="loadingIcon" [class]="'p-button-loading-icon' + icon" [ngClass]="iconClass()"></span>
<SpinnerIcon *ngIf="!loadingIcon" [styleClass]="iconClass() + ' p-button-loading-icon'" [spin]="true" />
<SpinnerIcon *ngIf="!loadingIcon" [styleClass]="spinnerIconClass()" [spin]="true" />
</ng-container>
<span *ngIf="loadingIconTemplate" class="p-button-loading-icon">
<ng-template *ngTemplateOutlet="loadingIconTemplate"></ng-template>
Expand Down Expand Up @@ -349,6 +349,12 @@ export class Button implements AfterContentInit {

@ContentChildren(PrimeTemplate) templates: QueryList<PrimeTemplate> | undefined;

spinnerIconClass(): string {
return Object.entries(this.iconClass())
.filter(([, value]) => !!value)
.reduce((acc, [key]) => acc + ` ${key}`, 'p-button-loading-icon');
}

iconClass() {
return {
'p-button-icon': true,
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/contextmenu/contextmenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,15 +342,15 @@ export class ContextMenu implements AfterViewInit, OnDestroy {
if (this.global) {
const documentTarget: any = this.el ? this.el.nativeElement.ownerDocument : 'document';
this.triggerEventListener = this.renderer.listen(documentTarget, this.triggerEvent, (event) => {
if(this.containerViewChild && this.containerViewChild.nativeElement.style.display !== 'none') {
if (this.containerViewChild && this.containerViewChild.nativeElement.style.display !== 'none') {
this.hide();
}
this.show(event);
event.preventDefault();
});
} else if (this.target) {
this.triggerEventListener = this.renderer.listen(this.target, this.triggerEvent, (event) => {
if(this.containerViewChild && this.containerViewChild.nativeElement.style.display !== 'none') {
if (this.containerViewChild && this.containerViewChild.nativeElement.style.display !== 'none') {
this.hide();
}
this.show(event);
Expand Down

0 comments on commit a483588

Please sign in to comment.