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 | Renders empty label when the label is not defined #9482

Closed
paulyipkh opened this issue Nov 2, 2020 · 15 comments · Fixed by #11904
Closed

Button | Renders empty label when the label is not defined #9482

paulyipkh opened this issue Nov 2, 2020 · 15 comments · Fixed by #11904
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@paulyipkh
Copy link

paulyipkh commented Nov 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

Current behavior
When no label is assigned to pButton, text   is rendered.

Expected behavior
When no label is assigned to pButton, the text should be empty, not space nor  

Minimal reproduction of the problem with instructions
https://stackblitz.com/edit/github-7rxhpm?file=src/app/app.component.html

https://github.com/primefaces/primeng/blob/master/src/app/components/button/button.ts
e.g. line 45 labelElement.appendChild(document.createTextNode(this.label||' '));
the expression this.label||' ' should be replaced with this.label === undefined || this.label === null ? '': this.label

@jonnomk
Copy link

jonnomk commented Nov 3, 2020

I totally agree with this.

@paulyipkh
Copy link
Author

paulyipkh commented Nov 3, 2020

In PrimeNg 9, I could center-align the content projected into a button? Does anybody know how this can be achieved in PrimeNg10 ?

<div class="ui-g ui-fluid" >
  <div class="ui-g-12">
    <button pButton>
      <div>Content</div>
      <i class="fa fa-home"></i>
    </button>
  </div>
</div>

image

@yigitfindikli yigitfindikli added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Nov 25, 2020
@rsilva1959
Copy link

workaround -> define label= "Edit", but include classes p-button-icon-only no-label where
::ng-deep .no-label>.p-button-label {
display: none;
}
<button *ngIf="config.actions.edit" label="Edit" pButton pRipple icon="pi pi-pencil" class="p-button-rounded p-button-success p-button-icon-only no-label p-mr-2" (click)="editItem(item)">
ugly, but works!

@jonnomk
Copy link

jonnomk commented Dec 1, 2020

Yeah, you can solve most things by applying custom styles, but you shouldn't really have to. The problem with a bunch of these components is that people have been using work-arounds to solve other issues too, and as a result the issues have been hanging around for years.

@SternBreeze
Copy link

any updates?

@h1ghland3r
Copy link

Any news?

@macorifice
Copy link

I have a similar issue, when I declare

<p-button
  icon="pi pi-refresh"
  (onClick)="refreshData()"
  pButton="Refresh data"
  label="Refresh data"
>

This is shown

image

So I decided to use the workaround written by @rsilva1959

<p-button
  class="no-label no-icon"
  icon="pi pi-refresh"
  style="margin-left: 30px; border-radius: 15px"
  (onClick)="refreshData()"
  pButton="Refresh data"
  label="Refresh data"
>

With this style

::ng-deep .no-label>.p-button-label {
  display: none;
}

::ng-deep .no-icon>.p-button-icon {
  display: none;
}

And the result is

image

@yigitfindikli yigitfindikli added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add labels Apr 6, 2021
@yigitfindikli yigitfindikli self-assigned this Apr 6, 2021
@yigitfindikli yigitfindikli added this to the 11.3.2 milestone Apr 6, 2021
@yigitfindikli yigitfindikli added LTS-PORTABLE Issue's fix will be ported to supported LTS versions LTS-FIXED-10.1.1 labels Apr 6, 2021
@yigitfindikli yigitfindikli removed the LTS-PORTABLE Issue's fix will be ported to supported LTS versions label Apr 13, 2021
@MaKCbIMKo
Copy link

I'm sorry, but I don't think it solved.

You closed this issue, but it still inserts &nbsp if you have no label.

I don't understand why it can't just render nothing if there is no label/icon?

@AlexanderVega
Copy link

Any news about this bug?

@sirwesley
Copy link

sirwesley commented Feb 27, 2022

https://stackblitz.com/edit/github-bd8xy8?file=src%2Fapp%2Fapp.component.html <--- example showing the bug.
&nbsp is added in the 'label' <span> when no label is defined.

<button pButton (click)="onClick()"></button>

renders

<button pbutton class="p-element p-button p-component">
<span class="p-button-label">&nbsp;</span>
</button>

expected render

<button pbutton class="p-element p-button p-component">
<span class="p-button-label"></span>
</button>

@AlexanderVega
Copy link

https://stackblitz.com/edit/github-bd8xy8?file=src%2Fapp%2Fapp.component.html <--- example showing the bug.

&nbsp is added in the 'label' <span> when no label is defined.


<button pButton (click)="onClick()"></button>

renders


<button pbutton class="p-element p-button p-component">

<span class="p-button-label">&nbsp;</span>

</button>

expected render


<button pbutton class="p-element p-button p-component">

<span class="p-button-label"></span>

</button>

What I did to solve this bug is get the class of element span inside the button tag and "display: none". Use this to a specific element, cause' maybe later you will need this element in another button

@drekthral
Copy link

Still not resolved. (╯‵□′)╯︵┻━┻

@DanilVezmenov
Copy link

Still not resolved!!! I HATE THIS BUG
NEED USE

 ::ng-deep .p-button-label {
        display: none !important;
      }

For hardcode resolve

@DanilVezmenov
Copy link

image
  span when label is empty

@Alhajras
Copy link

Alhajras commented Sep 5, 2022

The bug still exists!

@cetincakiroglu cetincakiroglu added this to the 14.0.3 milestone Sep 7, 2022
@cetincakiroglu cetincakiroglu changed the title When no label is assigned to pButton, the button should not render &nbsp; Button | Renders empty label when the label is not defined Sep 7, 2022
@cetincakiroglu cetincakiroglu reopened this Sep 7, 2022
@cetincakiroglu cetincakiroglu modified the milestones: 14.1.0, 14.1.1, 14.1.2 Sep 13, 2022
@cetincakiroglu cetincakiroglu modified the milestones: 14.1.2, 14.1.3 Sep 28, 2022
cetincakiroglu added a commit that referenced this issue Nov 9, 2022
Fixed #9482 - Button | Renders empty label when the label is not defined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

Successfully merging a pull request may close this issue.