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

Component: p-inputNumber [min] property NaN #15659

Closed
danielvieira1 opened this issue May 22, 2024 · 6 comments
Closed

Component: p-inputNumber [min] property NaN #15659

danielvieira1 opened this issue May 22, 2024 · 6 comments
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@danielvieira1
Copy link

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 danielvieira1 added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label May 22, 2024
@RogueTea
Copy link
Contributor

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?

@danielvieira1
Copy link
Author

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.

@quentin-ineat-ca
Copy link

@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

@salimmenari
Copy link

salimmenari commented Oct 17, 2024

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.

@Werffios
Copy link


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.

@mertsincan
Copy link
Member

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,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Projects
None yet
Development

No branches or pull requests

6 participants