Skip to content

Commit

Permalink
Fix #2871: InputNumber duplicating suffix when using decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Nov 11, 2022
1 parent 9b4a1d4 commit 0744095
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions components/lib/inputnumber/InputNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ export const InputNumber = React.memo(

_decimal.current.lastIndex = 0;

return decimalCharIndex !== -1 ? val1.split(_decimal.current)[0] + val2.slice(decimalCharIndex) : val1;
return decimalCharIndex !== -1 ? replaceSuffix(val1.split(_decimal.current)[0]) + val2.slice(decimalCharIndex) : val1;
}

return val1;
Expand All @@ -902,13 +902,17 @@ export const InputNumber = React.memo(
const valueSplit = value.split(_decimal.current);

if (valueSplit.length === 2) {
return valueSplit[1].replace(_suffix.current, '').trim().replace(/\s/g, '').replace(_currency.current, '').length;
return replaceSuffix(valueSplit[1]).length;
}
}

return 0;
};

const replaceSuffix = (value) => {
return value ? value.replace(_suffix.current, '').trim().replace(/\s/g, '').replace(_currency.current, '') : value;
};

const updateModel = (event, value) => {
if (props.onValueChange) {
props.onValueChange({
Expand Down

0 comments on commit 0744095

Please sign in to comment.