diff --git a/components/lib/inputnumber/InputNumber.js b/components/lib/inputnumber/InputNumber.js index ee0b4cf8d3..a4a157ff20 100644 --- a/components/lib/inputnumber/InputNumber.js +++ b/components/lib/inputnumber/InputNumber.js @@ -891,7 +891,11 @@ export const InputNumber = React.memo( _decimal.current.lastIndex = 0; - return decimalCharIndex !== -1 ? val1.split(_decimal.current)[0] + val2.slice(decimalCharIndex) : val1; + if (decimalCharIndex === -1) { + return val1; + } + + return replaceSuffix(val1.split(_decimal.current)[0]) + val2.slice(decimalCharIndex); } return val1; @@ -902,13 +906,21 @@ 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) => { + if (!value) { + return value; + } + + return value.replace(_suffix.current, '').trim().replace(/\s/g, '').replace(_currency.current, ''); + }; + const updateModel = (event, value) => { if (props.onValueChange) { props.onValueChange({