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: fixes #17296. Fix button directive loading for the new button directives #17295

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions packages/primeng/src/button/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -358,6 +362,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';
Expand Down