Skip to content

Float value getting converted to integer when there is only 0 after decimal point #895

Description

@Gnanavel76

In the input if user types 5.08 and then presses backspace instead of input showing 5.0 it is getting converted to 5. Used v5.4.5. In previous version (v5.2.0) it is working perfectly fine

20260412-1826-24.3485910.mp4

Code

import "./styles.css";
import React from 'react';
import { NumericFormat } from "react-number-format";
import { useState } from "react";
const Input = React.forwardRef((props, ref) => {
  return <input type="text" ref={ref} {...props}/>
})
export default function App() {
  const [valuesObj, setValuesObj] = useState({});

  return (
    <div className="App">
      <h3>
        Demo for <code>onValueChange</code>
        <h5>To see the value change, type something in the input field</h5>
      </h3>
      <p>
        <NumericFormat
          value={valuesObj.floatValue}
          suffix="x"
          decimalScale={2}
          onValueChange={(values, sourceInfo) => {
            setValuesObj(values);
          }}
        />
      </p>
      <hr />
      <code>{JSON.stringify(valuesObj)}</code>
      <hr />
    </div>
  );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions