Skip to content

Commit 16a980a

Browse files
committed
fix: decimalSeparator for ant-design/ant-design#28057.
1 parent 5d29b67 commit 16a980a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/InputNumber.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,11 @@ class InputNumber extends React.Component<Partial<InputNumberProps>, InputNumber
327327
let value = e.target.value.trim().replace(//g, '.');
328328

329329
if (isValidProps(this.props.decimalSeparator)) {
330-
value = value.replace(this.props.decimalSeparator, '.');
330+
// https://github.com/ant-design/ant-design/issues/28057
331+
// replace last separator
332+
// value = value.replace(this.props.decimalSeparator, '.');
333+
const regExp = new RegExp(`(.*)${this.props.decimalSeparator}`);
334+
value = value.replace(regExp, '$1.');
331335
}
332336

333337
return value;
@@ -452,7 +456,9 @@ class InputNumber extends React.Component<Partial<InputNumberProps>, InputNumber
452456
if (isValidProps(this.props.decimalSeparator)) {
453457
inputDisplayValueFormat = inputDisplayValueFormat
454458
.toString()
455-
.replace('.', this.props.decimalSeparator);
459+
.replace(/(.*)\./, `$1${this.props.decimalSeparator}`);
460+
// fixed https://github.com/ant-design/ant-design/issues/28057
461+
// .replace('.', this.props.decimalSeparator);
456462
}
457463

458464
return inputDisplayValueFormat;

0 commit comments

Comments
 (0)