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

FormControl with accepter InputNumber stores value as string #1720

Closed
simoncarbajal opened this issue Jun 3, 2021 · 1 comment
Closed

FormControl with accepter InputNumber stores value as string #1720

simoncarbajal opened this issue Jun 3, 2021 · 1 comment
Labels
component: InputNumber FAQ Frequently Asked Questions

Comments

@simoncarbajal
Copy link

What version of rsuite are you using?

4.10.2

What version of React are you using?

17.0.2

What browser are you using?

Chrome

Describe the Bug

As seen in the screenshots, I'm using the FormControl tag which is using an InputNumber accepter which should store the values I input as numbers, but instead, is stored as string. When the callback onChange is called in the form <Form onChange={callback} ...> the value of this field (i.e this FormControl) returns a string instead of a number.

Expected Behavior

The value for each FormControl should be stored with the most representative javascript type. So, if my FormControl has an InputNumber accepter, I would expect that the value stored is a number, not a string.

To Reproduce

I'll later update this issue including how to reproduce it

Screenshots

Screenshot 2021-06-03 at 22 56 05
Screenshot 2021-06-03 at 22 57 44

@simonguo
Copy link
Member

If it returns a number, InputNumber will not be able to support decimals.

For example, if we need to manually enter 1.5, the onChange event will be triggered every time the input is made. When the string 1. is entered, it is forced to be a number, and 1. becomes 1.

So we hope you can customize the processing data type in the onChange callback of InputNumber.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: InputNumber FAQ Frequently Asked Questions
Projects
None yet
Development

No branches or pull requests

3 participants