Skip to content

Commit

Permalink
Merge pull request #6664 from Rekl0w/Fix#6662
Browse files Browse the repository at this point in the history
Fix #6662: autocomplete value selection fix
  • Loading branch information
nitrogenous authored May 24, 2024
2 parents a532669 + e311332 commit aad5f28
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions components/lib/inputnumber/InputNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export const InputNumber = React.memo(
if (props.onKeyDown) {
props.onKeyDown(event);

// do not continue if the user defined event wants to prevent
// Do not continue if the user-defined event wants to prevent
if (event.defaultPrevented) {
return;
}
Expand Down Expand Up @@ -424,7 +424,6 @@ export const InputNumber = React.memo(

//enter and tab
case 'Tab':
case 'NumpadEnter':
case 'Enter':
case 'NumpadEnter':
newValueStr = validateValue(parseValue(inputValue));
Expand Down Expand Up @@ -542,13 +541,15 @@ export const InputNumber = React.memo(

default:
event.preventDefault();

let char = event.key;
const _isDecimalSign = isDecimalSign(char);
const _isMinusSign = isMinusSign(char);

if (((event.code.startsWith('Digit') || event.code.startsWith('Numpad')) && Number(char) >= 0 && Number(char) <= 9) || _isMinusSign || _isDecimalSign) {
insert(event, char, { isDecimalSign: _isDecimalSign, isMinusSign: _isMinusSign });
if (char) {
const _isDecimalSign = isDecimalSign(char);
const _isMinusSign = isMinusSign(char);

if ((event.code && (event.code.startsWith('Digit') || event.code.startsWith('Numpad')) && Number(char) >= 0 && Number(char) <= 9) || _isMinusSign || _isDecimalSign) {
insert(event, char, { isDecimalSign: _isDecimalSign, isMinusSign: _isMinusSign });
}
}

break;
Expand Down

0 comments on commit aad5f28

Please sign in to comment.