-
Notifications
You must be signed in to change notification settings - Fork 15
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: allow input field to have zero value #1647
base: master
Are you sure you want to change the base?
Conversation
🚀 Deployed on https://pr-1647--dhis2-ui.netlify.app |
value={ | ||
value === null || | ||
value === undefined || | ||
Number.isNaN(value) | ||
? '' | ||
: value | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this just use a nullish coalescing operator? Are we also trying to handle NaN
falsy values or just trying to make sure 0
can be passed?
value={ | |
value === null || | |
value === undefined || | |
Number.isNaN(value) | |
? '' | |
: value | |
} | |
value={value ?? ''} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, i was not sure here. I doubt NaN is ever going to be passed as a value, but I thought maybe safer to keep the previous behaviour for everything that is not 0, -0 or other forms of 0? But happy to change it as well. Do you think ??
would be better?
Quality Gate passedIssues Measures |
Description
This fixes changing number fields with value 0 to having value ""
Checklist
All points above should be relevant for feature PRs. For bugfixes, some points might not be relevant. In that case, just check them anyway to signal the work is done.
Screenshots
supporting text