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

Badge: 0 as a value passed to a badge does not render properly #2997

Closed
cmgriffing opened this issue Jun 19, 2022 · 4 comments · Fixed by #2998
Closed

Badge: 0 as a value passed to a badge does not render properly #2997

cmgriffing opened this issue Jun 19, 2022 · 4 comments · Fixed by #2998
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@cmgriffing
Copy link

Describe the bug

When passing numeric values to a Badge, a 0 will not render properly. It renders the badge at the size as if no value was passed. However it still also shows the 0 value.

Reproducer

https://codesandbox.io/s/jolly-hugle-w9rwor?file=/src/App.js

PrimeReact version

8.1.1

React version

18.x

Language

TypeScript

Build / Runtime

Next.js

Browser(s)

No response

Steps to reproduce the behavior

Pass a numeric 0 value to the Badge. A string 0 value works as expected.

Expected behavior

It should render like other numeric values do.

@cmgriffing cmgriffing added Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible Type: Bug Issue contains a defect related to a specific component. labels Jun 19, 2022
@melloware
Copy link
Member

I will look I have fixed similar issues before.

@cmgriffing
Copy link
Author

cmgriffing commented Jun 19, 2022

I would be happy to submit a PR. My instinct is to coerce any value prop to a string. Does that sound like the right approach?

edit: I could also just explicitly check for a 0 value and only coerce that.

@melloware
Copy link
Member

Cool if you want to submit a PR I will give you a hint it's pretty easy you just need to wrap the value prop in the function ObjectUtils.isNotEmpty it handles the 0 case

@cmgriffing
Copy link
Author

cmgriffing commented Jun 20, 2022

Thanks. I might not get to it until next Sunday at this point. So, if you (or anyone else) want it fixed sooner, feel free.

melloware added a commit to melloware/primereact that referenced this issue Jun 20, 2022
@melloware melloware self-assigned this Jun 20, 2022
@melloware melloware removed the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jun 20, 2022
@melloware melloware added this to the 8.2.0 milestone Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants