Skip to content

Commit

Permalink
fix(input-number): unable to input a decimal point (#5339)
Browse files Browse the repository at this point in the history
  • Loading branch information
betavs authored Nov 17, 2023
1 parent 3374bb9 commit b5065c1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions components/lib/inputnumber/InputNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b5065c1

Please sign in to comment.