From edb62e69b006407152765a2c2bcf25df043d864c Mon Sep 17 00:00:00 2001 From: liuqiang Date: Fri, 6 Nov 2020 17:30:50 +0800 Subject: [PATCH 1/2] fix: double onchange and render double number pointer in input when input first render use chinese input method and input full stop --- src/InputNumber.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/InputNumber.tsx b/src/InputNumber.tsx index a71139eb..6ae52f95 100644 --- a/src/InputNumber.tsx +++ b/src/InputNumber.tsx @@ -255,7 +255,6 @@ class InputNumber extends React.Component, InputNumber onChange = e => { const { onChange } = this.props; - if (this.state.focused) { this.inputting = true; } @@ -324,7 +323,10 @@ class InputNumber extends React.Component, InputNumber getValueFromEvent(e) { // optimize for chinese input expierence // https://github.com/ant-design/ant-design/issues/8196 - let value = e.target.value.trim().replace(/。/g, '.'); + let value = e.target.value + .trim() + .replace(/。/g, '.') + .replace(/\.+/g, '.'); if (isValidProps(this.props.decimalSeparator)) { value = value.replace(this.props.decimalSeparator, '.'); From c583bdaa5158f7549ff4494e68d710abb5cbdb5c Mon Sep 17 00:00:00 2001 From: liuqiang Date: Sat, 7 Nov 2020 08:45:56 +0800 Subject: [PATCH 2/2] update: merger regexp simple --- src/InputNumber.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/InputNumber.tsx b/src/InputNumber.tsx index 6ae52f95..db25312c 100644 --- a/src/InputNumber.tsx +++ b/src/InputNumber.tsx @@ -323,10 +323,7 @@ class InputNumber extends React.Component, InputNumber getValueFromEvent(e) { // optimize for chinese input expierence // https://github.com/ant-design/ant-design/issues/8196 - let value = e.target.value - .trim() - .replace(/。/g, '.') - .replace(/\.+/g, '.'); + let value = e.target.value.trim().replace(/。|\.。/g, '.'); if (isValidProps(this.props.decimalSeparator)) { value = value.replace(this.props.decimalSeparator, '.');