primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Button.ts class name typo

Open BFCatalin opened this issue 9 years ago • 1 comments

[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)

Current behavior The current code line 80 has a missing space between ui-cli and fa CSS classes: this.domHandler.findSingle(this.el.nativeElement, '.fa').className = iconPosClass + ' ui-clifa fa-fw ' + this.icon; and results in the following error: ERROR TypeError: Cannot set property 'className' of null at Button.set [as icon] (button.js:75)

Because this space is missing when changing a button icon based on a condition the icon will not be assigned since the findSingle(...) will return a null The issues is resolved by adding the additional 'fa' class to the icon condition (workaround based on the TypeScript code): [icon]="showAdvanced ? 'fa fa-cog' : 'fa fa-cogs'"

Expected behavior The fa class should be assigned since it is used as a query.

Minimal reproduction of the problem with instructions <button pButton id="btnOptions" type="button" [icon]="showAdvanced ? 'fa-cog' : 'fa-cogs'" (click)="showAdvanced = !showAdvanced" label="{{ showAdvanced ? 'Basic' : 'Advanced' }} Options"></button>

What is the motivation / use case for changing the behavior? Allows the change of a button to toggle between basic and advanced options I tried modifying the local button.ts file to contain: this.domHandler.findSingle(this.el.nativeElement, '.fa').className = iconPosClass + ' ui-cli fa fa-fw ' + this.icon; This change seems to have fixed the issue I was having, but I will go with the workaround written above to avoid having to distribute a custom primeng.

Please tell us about your environment:

Windows 2012 R2, VS 2017, npm

  • Angular version: > 4.1.2

  • PrimeNG version: 4.1.0-rc2

  • Browser: all

  • Language: Typescript 2.3.2 ES5

  • Node (for AoT issues): node --version = v7.10.0

BFCatalin avatar Jul 12 '17 07:07 BFCatalin

I can confirm this behavior on 4.1.0. Thanks for your workaround :)

ARandomDude avatar Jul 16 '17 15:07 ARandomDude