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

Button lose class style after label update with after primeng 9.1.0 #8996

Closed
Rotzbua opened this issue Jul 2, 2020 · 11 comments
Closed

Button lose class style after label update with after primeng 9.1.0 #8996

Rotzbua opened this issue Jul 2, 2020 · 11 comments
Assignees
Labels
LTS-FIXED-9.1.4 Fixed in PrimeNG LTS 9.1.4 Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@Rotzbua
Copy link
Contributor

Rotzbua commented Jul 2, 2020

I'm submitting a ... (check one with "x")

[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Plunkr Case (Bug Reports)

Bug with Primeng 9.1.2 and angular 10:
https://stackblitz.com/edit/github-qbkr34?file=src%2Fapp%2Fapp.component.html

Bug with Primeng 9.1.3 and angular 9:
https://stackblitz.com/edit/github-f3ydbw?file=package.json

Work with Primeng 9.1.0 and angular 9:
https://stackblitz.com/edit/github-f3ydbw-vsqqg3?file=package.json

Current behavior

If label changed dynamically, the style by class is lost.

Just with angular 10 observed, not with 9. I'm not sure if this is an error of Angular or Primeng.

Expected behavior

No style change on update.

Minimal reproduction of the problem with instructions

Use dynamic label update:
´<button pButton [label]="counter.toString()">´

What is the motivation / use case for changing the behavior?

Works without problems with Angular 9.
Works without problems with primeng 9.1.0.

Please tell us about your environment:

  • Angular version: 10.0.2
  • PrimeNG version: 9.1.2
  • Browser: Chrome Firefox
  • Language: [all | TypeScript X.X | ES6/7 | ES5]

  • Node (for AoT issues): node --version = 12

@soroushNeshat
Copy link

i have same issue with PrimeNG version: 9.1.2 and Angular version: 9.1.11

@alixdehghani
Copy link

I have same issue ... PrimeNG version: 9.1.2 and Angular version: 9.1

@KevinKoorani
Copy link

I have this problem too. There is a simple solution, but the PrimeNG team does not apply it

@mjfard
Copy link

mjfard commented Jul 8, 2020

PrimeNG team! Please do some thing about this!

@Rotzbua Rotzbua changed the title Button lose class style after label update with Angular 10 Button lose class style after label update with after primeng 9.1.0 Jul 8, 2020
@Rotzbua
Copy link
Contributor Author

Rotzbua commented Jul 8, 2020

@ALL Thanks for feedback. Updated bug description. Primeng 9.1.0 seems the latest version without this bug.

@soroushNeshat
Copy link

soroushNeshat commented Jul 8, 2020

@Rotzbua yes extactly. this bug exists since primeng v9.1.1 .

this bug was created in this commit: dbe0bd8

    setStyleClass() {
        let styleClass = this.getStyleClass();
        this.el.nativeElement.className = styleClass; // => this line of code overrides all initial css classes
    }

@soroushNeshat
Copy link

soroushNeshat commented Jul 8, 2020

a possible soultion is to hold initial css classes in a private field like this :

    ngAfterViewInit() {
        this._initialStyleClass = this.el.nativeElement.className;
        ....
    }

    private _initialStyleClass : string; // introduce a new field to hold the initial css classes

    setStyleClass() {
        let styleClass = this.getStyleClass();
        this.el.nativeElement.className = styleClass + this._initialStyleClass;
    }

@cagataycivici cagataycivici self-assigned this Jul 27, 2020
@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Jul 27, 2020
@cagataycivici cagataycivici added this to the 10.0.0 milestone Jul 27, 2020
@cagataycivici
Copy link
Member

@yigitfindikli We should add it to 9.x LTS as well.

@yigitfindikli yigitfindikli added the LTS-FIXED-9.1.4 Fixed in PrimeNG LTS 9.1.4 label Aug 17, 2020
@ryann3588
Copy link

ryann3588 commented Jul 28, 2021

This is still an issue when using [ngClass] [class.class-name] bindings with buttons. If you dynamically change the text of the button which also triggers a class change, the dynamic class gets overridden.

On prime 11.

@EnasDiab
Copy link

EnasDiab commented Oct 3, 2021

Still have it with primeng 12 angular 12 when using [ngClass] , any solution ?

@cyberavisror
Copy link

I found workaround for this scenario, try to add method that calculates the classes instead of ngClass and use cornerStyleClass input to inject them.

it's bad practice, but it works :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTS-FIXED-9.1.4 Fixed in PrimeNG LTS 9.1.4 Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

10 participants