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

Number input allows extra characters despite min and max #3309

Closed
dgastudio opened this issue Jul 26, 2023 · 3 comments
Closed

Number input allows extra characters despite min and max #3309

dgastudio opened this issue Jul 26, 2023 · 3 comments

Comments

@dgastudio
Copy link

What version of rsuite are you using?

5.31

What version of React are you using?

nextjs 13

What version of TypeScript are you using (if any)?

No response

What browser are you using?

Chrome

Describe the Bug

https://rsuitejs.com/components/input-number/
is possible to add + and - to field values
i can't understand about -, but it shoud not work if you have set 0 as min
but +??

CleanShot 2023-07-26 at 15 57 16@2x

it can be cleared by form state updates, but...

thank you

Expected Behavior

only number are allowed in input
in case "min" param is not set, - can be applied
but not +

To Reproduce

No response

@SevenOutman
Copy link
Member

@dgastudio Thanks for raising this. It's indeed unexpected to allow trailing plus/minus signs if the principle of InputNumber is "only omit value that isNaN(value) is false` IMO. It should be fixed.

But I believe + should be allowed at the beginning of value, acting as "positive sign" (when max is above 0), WDYT?

@dgastudio
Copy link
Author

dgastudio commented Jul 27, 2023

@SevenOutman thank you for your response.
IMHO, all depends on backend and simplicity.

  • "-" becomes a negative number
  • the presence of + or its absence, is a positive number. have you ever seen +signed numbers somewhere?

i'm working on backend based on nestjs, numberfield is typed as number, so + is automatically removed.

i mean, is a little bit tricky to handle data in this widget, but, take a look at this example. it's how it should work in my opinion
https://www.bryntum.com/products/scheduler/docs/api/Core/widget/NumberField

thank you

@SevenOutman
Copy link
Member

@dgastudio After some more investigation, I realized that it's the native <input type="number" /> that is allowing those characters, and it's the expected behavior per specification.

I'm leaving it as is for now, until we find the necessity to add additional constraints to alter what we should expect from InputNumber despite specification.

@SevenOutman SevenOutman removed this from the Backlog milestone Aug 15, 2023
@SevenOutman SevenOutman closed this as not planned Won't fix, can't repro, duplicate, stale Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants