From b5065c1524652bb6d44117889749b2b517d82bec Mon Sep 17 00:00:00 2001 From: betavs <34408516+betavs@users.noreply.github.com> Date: Fri, 17 Nov 2023 21:48:01 +0800 Subject: [PATCH] fix(input-number): unable to input a decimal point (#5339) --- components/lib/inputnumber/InputNumber.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/lib/inputnumber/InputNumber.js b/components/lib/inputnumber/InputNumber.js index cad34e7c5c..e73cc328a7 100644 --- a/components/lib/inputnumber/InputNumber.js +++ b/components/lib/inputnumber/InputNumber.js @@ -853,10 +853,14 @@ export const InputNumber = React.memo( selectionEnd = sRegex.lastIndex + tRegex.lastIndex; inputEl.setSelectionRange(selectionEnd, selectionEnd); } else if (newLength === currentLength) { - if (['insert', 'delete-back-single', 'delete-range', 'spin'].includes(operation)) { - inputEl.setSelectionRange(selectionEnd, selectionEnd); + if (operation === 'insert' || operation === 'delete-back-single') { + const newSelectionEnd = selectionEnd + Number(isDecimalSign(value) || isDecimalSign(insertedValueStr)); + + inputEl.setSelectionRange(newSelectionEnd, newSelectionEnd); } else if (operation === 'delete-single') { inputEl.setSelectionRange(selectionEnd - 1, selectionEnd - 1); + } else if (operation === 'delete-range' || operation === 'spin') { + inputEl.setSelectionRange(selectionEnd, selectionEnd); } } else if (operation === 'delete-back-single') { let prevChar = inputValue.charAt(selectionEnd - 1);