Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: decimalSeparator for https://github.com/ant-design/ant-design/is… #279

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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