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

It is impossible to type fractional digits on InputNumber #1380

Closed
julianomqs opened this issue May 22, 2020 · 10 comments
Closed

It is impossible to type fractional digits on InputNumber #1380

julianomqs opened this issue May 22, 2020 · 10 comments
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@julianomqs
Copy link

julianomqs commented May 22, 2020

There is no guarantee in receiving an immediate response in GitHub Issue Tracker, If you'd like to secure our response, you may consider PrimeReact PRO Support where support is provided within 4 business hours

I'm submitting a ... (check one with "x")

[X] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://forum.primefaces.org/viewforum.php?f=57

Codesandbox Case (Bug Reports)
https://codesandbox.io/s/inputnumberbug-5shee

Current behavior
It is impossible to type the fractional part of a number (decimals or cents) because it is not possible to type commas or dots.

Expected behavior
Be able to type the fractional part of a number (decimals or cents) of a number.

Minimal reproduction of the problem with instructions
In the codesandbox above or in the PrimeReact InputNumber showcase, try to input a value with fractional digits, e.g 1500.50.

You will see it's not possible to type the dot or comma, so it is impossible to type the fractional part of a number.

Please tell us about your environment:
OS: Ubuntu 18.04
Node version: v12.16.1
NPM version: 6.13.4

  • React version: ^16.13.1

  • PrimeReact version: ^4.2.1

  • Browser: Chrome 83.0.4103.61 but I think it will happen in any other browser

  • Language: TypeScript 3.9.3 and JS

Observation
This situation occurs too in the PrimeVue InputNumber component.

@mertsincan mertsincan added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Jun 4, 2020
@igor-co
Copy link

igor-co commented Jun 10, 2020

Same problem.

@VsevolodGolovanov
Copy link

This is probably caused by the desire to guarantee a value of a number type only. But this goal seems impossible. If the user typed in "123," - that's a string. You can't convert it to a number without losing information that the user intends to type a fraction part. If the component would keep an internal string buffer that comes with its own problems too. Yes, instead of a string buffer you can e.g. keep some sort of "user started a fraction" boolean - makes no difference. Internal hidden state WILL get stale, out of sync, there is just no way around it. You need to expose it.

So IMHO...

  1. InputNumber's default value/onChange contract should be that it could be a number of a string.
  2. Maybe InputNumber should provide alternative API (onChangeNumber?) for cases that are interested only in number, it works with a hidden internal string buffer.
  3. InputNumber should forcefully coerce string to number at certain moments like blur. These moments could be configurable.

@VsevolodGolovanov
Copy link

Same problem (immediately coercing to valid number value on each keypress) makes it hard to input values if you have something like min={10} max={200} set. A lot of invalid intermediate states.

@suatalim
Copy link

suatalim commented Aug 9, 2020

Same problem. Needs some improvements over typing experience. It's nearly impossible to enter the desired decimal number.
Also "del" button not updating value.

@julianomqs
Copy link
Author

Why this is an enhancement? It is clearly a bug.

@mertsincan mertsincan changed the title BUG - InputNumber - It is impossible to type fractional digits It is impossible to type fractional digits on InputNumber Aug 20, 2020
@mertsincan mertsincan self-assigned this Aug 20, 2020
@mertsincan mertsincan added this to the 5.0 milestone Aug 20, 2020
@mertsincan
Copy link
Member

Hi,

Thanks a lot for all feedbacks! On 5.0, the decimal separator can be typed in inputNumber. In addition, some enhancements were made according to the feedbacks received in this component.

  • Del key support
  • Range insert fix
  • Cursor position after multiple values is inserted
  • Paste issues
    etc.

Thanks again!
Best Regards,

@maximilianweidenauer
Copy link

I'm on version 5.0.0-rc.1 and I still can't put a decimal separator in InputNumber

@Anubarak
Copy link

@mertsincan Unfortunately I still cannot type decimal separators in the examples here and I cannot delete them.
Are there any special attributes you need to set?

@VsevolodGolovanov
Copy link

Continued in #1768.

@melloware
Copy link
Member

Here is my 8.0.0 sandbox of this can someone try and replicate the issue again please.

See: https://codesandbox.io/s/primereact-test-forked-fd0ukd?file=/src/index.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

No branches or pull requests

8 participants