Skip to content

Commit

Permalink
fix: decimalSeparator for ant-design/ant-design#28057.
Browse files Browse the repository at this point in the history
  • Loading branch information
xuqiang1227 committed Nov 30, 2020
1 parent 5d29b67 commit 16a980a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/InputNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,11 @@ class InputNumber extends React.Component<Partial<InputNumberProps>, InputNumber
let value = e.target.value.trim().replace(//g, '.');

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

return value;
Expand Down Expand Up @@ -452,7 +456,9 @@ class InputNumber extends React.Component<Partial<InputNumberProps>, InputNumber
if (isValidProps(this.props.decimalSeparator)) {
inputDisplayValueFormat = inputDisplayValueFormat
.toString()
.replace('.', this.props.decimalSeparator);
.replace(/(.*)\./, `$1${this.props.decimalSeparator}`);
// fixed https://github.com/ant-design/ant-design/issues/28057
// .replace('.', this.props.decimalSeparator);
}

return inputDisplayValueFormat;
Expand Down

0 comments on commit 16a980a

Please sign in to comment.