Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix button loading issue #13489 #13676

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/app/components/button/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,10 @@ 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.icon && !this.loading) {
iconElement && this.htmlElement.removeChild(iconElement);
return;
}

if (this.loading && !this.loadingIcon && iconElement) {
iconElement.innerHTML = this.spinnerIcon;
} else if (iconElement?.innerHTML) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a personal opinion but always I prefer a simple if instead else if.
It's cleaner for me, but PrimeNG Team will decide :). Thanks for your contribution

if (this.loading && !this.loadingIcon && iconElement) {
    iconElement.innerHTML = this.spinnerIcon;
}

if (iconElement?.innerHTML) {
    iconElement.innerHTML = '';
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh for sure, I have zero preference. Just would really like to see this make it in the next release since it's blocking us from upgrading since all of our buttons are use the pButton directive instead of the p-button element.

Though I think to avoid just undoing the loading spinner it would have to be:

if (this.loading && !this.loadingIcon && iconElement) {
    iconElement.innerHTML = this.spinnerIcon;
}

if (!this.loading && iconElement?.innerHTML) {
    iconElement.innerHTML = '';
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a PR fixing something similar in pButton and <p-button time ago #13363

Maybe I forgot something and with your code I hope works 100%

iconElement.innerHTML = '';
}

if (iconElement) {
Expand Down