From 463ba5c70b80127a535ae31e0f3bf2c00889a524 Mon Sep 17 00:00:00 2001 From: Kiril Volskiy <118115736+KirilCycle@users.noreply.github.com> Date: Fri, 17 May 2024 20:16:35 +0300 Subject: [PATCH] Fix #6632 InputOtp keyboard navigation (#6638) * fix: do not call preventDef on submit and tab keys * update: default case condition * fix: change condition * make code cleaner --- components/lib/inputotp/InputOtp.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/lib/inputotp/InputOtp.js b/components/lib/inputotp/InputOtp.js index ddce03e275..cd32c8eebf 100644 --- a/components/lib/inputotp/InputOtp.js +++ b/components/lib/inputotp/InputOtp.js @@ -163,8 +163,14 @@ export const InputOtp = React.memo( break; } + case 'Tab': + + case 'Enter': { + break; + } + 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 + //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')) { event.preventDefault(); }