Component: p-inputNumber [min] property NaN
Describe the bug
When I specify [min]=null in the p-inputNumber component, this happens:
NaN is set instead of null. I can not enter negative values anymore unless I use the arrow keys.
Environment
I am using regular Angular with PrimeNG
Reproducer
No response
Angular version
17.3.5
PrimeNG version
17.15.0
Build / Runtime
Angular CLI App
Language
TypeScript
Node version (for AoT issues node --version)
18.18.2
Browser(s)
Chrome
Steps to reproduce the behavior
<p-inputNumber mode="currency" locale="de-DE" [min]="null" currency="EUR" [ngModel]="null"
Now try to add a negative value without using the step buttons or arrow keys
Expected behavior
if null is specified in the "min" property, you should be able to add negative values.
In the demo you are able to use negative numbers without defining a min. Could you please try this and see if it works for you?
Yes, if you don't define it, its fine. It happened for me because I wrapped the primeNG component and default value that is parsed into the primeNG component is null.
@RogueTea Same problem here.
If min is defined as : null | undefined => impossible to go below 0. if min is not defined => Works fine
Here is the stackblitz : https://stackblitz.com/edit/j7uken?file=src%2Fapp%2Finput-number-numerals-demo.html Last version Primeng 17.18.3
If min is defined as : null | undefined => impossible to go below 0. if min is not defined => Works fine
Same situation here with PrimeNG 17.18.11. It was working fine with PrimeNG 16.9.15 as we can see here : https://stackblitz.com/edit/vrfmbo
The issue arises due to the use of the numberAttribute transformer on the min @Input. When the provided value is not a valid number, it defaults to NaN.
The allowMinusSign method of the InputNumber component only permits a minus sign if min value is null, undefined, or less than zero. Since the value is NaN in this case, the minus sign is not allowed.
Hi, I am experiencing the same issue with the _p-inputNumber_ component in PrimeNG. When I specify [min]=null, I cannot enter negative values, even if I use the arrow keys. Removing the min attribute or setting it to null does not resolve the issue. Here is the relevant code snippet:
Environment:
- Angular CLI: 18.2.11
- Angular version: 18.2.11
- PrimeNG version: 17.18.11
- Node version: 23.4.0 (Unsupported)
- Package Manager: npm 10.9.2
- OS: win32 x64
- Browser: Microsoft Edge Version 131.0.2903.99 (Official build) (64-bit)
Steps to reproduce:
Use the p-inputNumber component with [min]=-40.
Try to enter a negative value, even using the arrow keys.
Expected behavior: If -40 is specified in the min property, it should be possible to add negative values.
This should provide enough detail for others to understand and potentially reproduce the issue.
Hi,
So sorry for the delayed response! Improvements have been made to many components recently, both in terms of performance and enhancement. Therefore, this improvement may have been developed in another issue ticket without realizing it. You can check this in the documentation and try the latest PrimeNG version(v19). If there is no improvement on this, can you open a new issue so we can include it in our roadmap?
Thanks a lot for your understanding! Best Regards,
The issue is still not resolved As mentioned before: @quentin-ineat-ca If min is defined as : null | undefined => impossible to add "-" before the number if min is not defined => Works fine
@mertsincan can you open this issue again please ?
I don’t fully agree with the situation. If you wrap the component and reuse it, and you can’t define in advance whether the min/max fields will have a value, then the solution should be undefined. Not null, but undefined. This still worked in PrimeNG 16.