From 68907925737281742a100798a114b54a3827b7b3 Mon Sep 17 00:00:00 2001
From: Batuhan Tomo <91488737+Rekl0w@users.noreply.github.com>
Date: Thu, 6 Jun 2024 12:33:39 +0300
Subject: [PATCH] Fix #6730: fix InputOtp keyDown (#6731)
---
components/lib/inputotp/InputOtp.js | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/components/lib/inputotp/InputOtp.js b/components/lib/inputotp/InputOtp.js
index cd32c8eebf..0c2104caa6 100644
--- a/components/lib/inputotp/InputOtp.js
+++ b/components/lib/inputotp/InputOtp.js
@@ -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();
}
@@ -217,7 +217,14 @@ export const InputOtp = React.memo(
},
ptm('input')
);
- const inputElement = props?.inputTemplate ? ObjectUtils.getJSXElement(props?.inputTemplate, { events: inputElementEvents, props: inputElementProps }) : ;
+ const inputElement = props?.inputTemplate ? (
+ ObjectUtils.getJSXElement(props?.inputTemplate, {
+ events: inputElementEvents,
+ props: inputElementProps
+ })
+ ) : (
+
+ );
const inputElements = [inputElement, ...createInputElements(remainingInputs - 1)];
return inputElements;