fix: prevent OTP input focus from advancing when previous input is empty (#51664)

Co-authored-by: Salim Abubakar <salimabubakar@Salims-MacBook-Air.local>
This commit is contained in:
Salim Abubakar 2024-11-18 03:18:05 +01:00 committed by GitHub
parent f474bf18d8
commit f459efef43
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -208,7 +208,7 @@ const OTP = React.forwardRef<OTPRef, OTPProps>((props, ref) => {
const nextCells = patchValue(index, txt);
const nextIndex = Math.min(index + txt.length, length - 1);
if (nextIndex !== index) {
if (nextIndex !== index && nextCells[index] !== undefined) {
refs.current[nextIndex]?.focus();
}