Skip to content

Commit

Permalink
Fix primefaces#6730: fix InputOtp keyDown (primefaces#6731)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rekl0w authored Jun 6, 2024
1 parent b0198a5 commit 6890792
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions components/lib/inputotp/InputOtp.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export const InputOtp = React.memo(

default: {
//Prevent non-numeric characters from being entered if integerOnly is true or if the length of the input is greater than the specified length
if ((props?.integerOnly && !((event.code.startsWith('Digit') || event.code.startsWith('Numpad')) && Number(event.key) >= 0 && Number(event.key) <= 9)) || (tokens.join('').length >= props.length && event.code !== 'Delete')) {
if ((props?.integerOnly && !(Number(event.key) >= 0 && Number(event.key) <= 9)) || (tokens.join('').length >= props.length && event.code !== 'Delete')) {
event.preventDefault();
}

Expand Down Expand Up @@ -217,7 +217,14 @@ export const InputOtp = React.memo(
},
ptm('input')
);
const inputElement = props?.inputTemplate ? ObjectUtils.getJSXElement(props?.inputTemplate, { events: inputElementEvents, props: inputElementProps }) : <InputText {...inputElementProps} {...inputElementEvents} />;
const inputElement = props?.inputTemplate ? (
ObjectUtils.getJSXElement(props?.inputTemplate, {
events: inputElementEvents,
props: inputElementProps
})
) : (
<InputText {...inputElementProps} {...inputElementEvents} />
);
const inputElements = [inputElement, ...createInputElements(remainingInputs - 1)];

return inputElements;
Expand Down

0 comments on commit 6890792

Please sign in to comment.