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

Formio Embed JS number field incorrect behavior with decimalLimit flag #5802

Open
dipankarmedhi91 opened this issue Sep 10, 2024 · 0 comments

Comments

@dipankarmedhi91
Copy link

Describe the bug
I am rendering a Formio defined form using the Formio Embed JS definition as the web app just needs to render the form using the JSON output of a Form built using Formio builder.
For a number field if we add a decimalLimit flag the input value changes on focus out to get truncated and prefixed with a Zero 0, this behavior continues if we keep focusing in and out of the number field until the value reaches only Zero 0.

{
    type: 'number',
    key: 'number',
    label: 'Enter a number',
    input: true,
    decimalLimit: 0
}

Version/Branch
N/A as we are using https://cdn.form.io/js/formio.embed.js

To Reproduce
JS Fiddle: https://jsfiddle.net/Lhtqb1oy/2/
Steps to reproduce the behavior:

  1. Open the JSFiddle above
  2. enter some number and tab out
  3. the Input will get truncated and get prefixed with a 0, focus in and out
  4. the truncation will continue until only 0 is left
  5. If we remove decimalLimit flag from the number field definition, the input behaves as expected

Expected behavior
The input shpuld not get truncated and prefixed with 0

Screenshots

  1. JSFiddle
Full Window
  1. User typed a number
Screenshot 1
  1. Tab/Blur out
Screenshot 2
  1. Tab in-n-out
Screenshot 3
  1. Tab in-n-out, only 0 is left at the end
Screenshot 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant