Skip to content

Shows decimals should be optional #132

@karina2004liz

Description

@karina2004liz

Hi Renato!

  • Bug
  • Feature request
  • Code refactor
  • Continuous Integration (CI) improvement
  • Changes in documentation (docs)
  • Other (describe)

What is the current behavior?

Currently we can add decimals in the "decimalPlaces" property and these are shown by default, if we put {decimalPlaces: 2} the value that is shown will be "0.00". It would be great if they could add an additional property like "fixedDecimalScale" which is a boolean that allows to show or not show decimals, even if they are allowed. That way our displayed value could stay at "0", but we could add decimals if needed

What is the expected behavior?

Add the "fixedDecimalScale" property that allows us to make it optional to show the decimals

import { createNumberMask } from 'redux-form-input-masks';

const myCustomNumberMask = createNumberMask({
decimalPlaces: 2,
fixedDecimalScale: false
});

<Field
name="my-numeric-field"
component={TextField}
type="tel"
validate={validation}
{...myCustomNumberMask}
/>

Final result would be in the input value as 0 but if the user add decimals just can add two digits,
initial value = 0
user add value = 10
Final result = 10
user wants add decimals = 10.5
Final result = 10.50

In this way, with prop "fixedDecimalScale" we can choose if we want to show decimals values when the input is rendered, if this prop is false the initial value is 0, if not the initial value would be 0.00

Is it this possible?

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