Skip to content

Commit

Permalink
Fix primefaces#6324: InputNumber allowing accent/dead characters
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Apr 9, 2024
1 parent b48c0dc commit b69f82f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion components/lib/inputnumber/InputNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,19 @@ export const InputNumber = React.memo(

if (isSpecialChar.current) {
event.target.value = lastValue.current;
isSpecialChar.current = false;
}

isSpecialChar.current = false;
if (DomHandler.isAndroid()) {
return;
}

// #6324 Chrome is allowing accent-dead characters through...
const inputType = event.nativeEvent.inputType;
const data = event.nativeEvent.data;
if (inputType === 'insertText' && /\D/.test(data)) {
event.target.value = lastValue.current;
}
};

const onInputAndroidKey = (event) => {
Expand Down Expand Up @@ -531,6 +541,7 @@ export const InputNumber = React.memo(

default:
event.preventDefault();
event.stopPropagation();

let char = event.key;
const _isDecimalSign = isDecimalSign(char);
Expand Down

0 comments on commit b69f82f

Please sign in to comment.