Skip to content

Commit

Permalink
Fix #6632 InputOtp keyboard navigation (#6638)
Browse files Browse the repository at this point in the history
* fix: do not call preventDef on submit and tab keys

* update: default case condition

* fix: change condition

* make code cleaner
  • Loading branch information
KirilCycle authored May 17, 2024
1 parent 98c25fb commit 463ba5c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion components/lib/inputotp/InputOtp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 463ba5c

Please sign in to comment.