Skip to content

Commit

Permalink
[DDW-543] Fix rounding mode bug
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikGuzei committed Jan 27, 2021
1 parent 8b3ef68 commit 489b255
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions source/components/NumericInput.js
Expand Up @@ -44,6 +44,7 @@ class NumericInputBase extends Component<NumericInputProps, State> {
allowSigns: true,
context: createEmptyContext(),
readOnly: false,
roundingMode: BigNumber.ROUND_FLOOR,
theme: null,
themeId: IDENTIFIERS.INPUT,
themeOverrides: {},
Expand Down Expand Up @@ -326,13 +327,13 @@ class NumericInputBase extends Component<NumericInputProps, State> {
return this.props.bigNumberFormat ?? BigNumber.config().FORMAT;
}

bigNumberToFormattedString(number: BigNumber.Instance) {
bigNumberToFormattedString(number: ?BigNumber.Instance) {
const { bigNumberFormat, decimalPlaces, roundingMode } = this.props;
const result = number.toFormat(decimalPlaces, roundingMode, {
const result = new BigNumber(number).toFormat(decimalPlaces, roundingMode, {
...BigNumber.config().FORMAT, // defaults
...bigNumberFormat, // custom overrides
});
return result === 'NaN' ? null : result;
return result === 'NaN' ? '' : result;
}

formattedValueToBigNumber(value: string) {
Expand Down

0 comments on commit 489b255

Please sign in to comment.