primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Component: p-inputNumber [min] property NaN

Open danielvieira1 opened this issue 1 year ago • 4 comments

Describe the bug

When I specify [min]=null in the p-inputNumber component, this happens: image

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.

danielvieira1 avatar May 22 '24 14:05 danielvieira1

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?

RogueTea avatar May 23 '24 13:05 RogueTea

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.

danielvieira1 avatar May 27 '24 08:05 danielvieira1

@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

quentin-ineat-ca avatar Jul 04 '24 14:07 quentin-ineat-ca

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.

salimmenari avatar Oct 17 '24 12:10 salimmenari


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:

image

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.

Werffios avatar Dec 19 '24 14:12 Werffios

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,

mertsincan avatar Dec 25 '24 13:12 mertsincan

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

shlomiah avatar Jan 13 '25 10:01 shlomiah

@mertsincan can you open this issue again please ?

danielvieira1 avatar Jan 13 '25 10:01 danielvieira1

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.

figlerdavid avatar May 21 '25 08:05 figlerdavid