fix: OTP auto-submit not firing when typing manually
String.includes("") always returns true in JavaScript, so the condition
`!newValue.includes("")` was always false, preventing onComplete from
ever firing on manual input. Only paste worked because it uses a
separate code path. The length check alone is sufficient since empty
digits produce a shorter joined string.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9754c73b64
commit
6be28b4fb5
@ -65,7 +65,7 @@ function useOtpHandlers({
|
||||
const newValue = newDigits.join("");
|
||||
onChange(newValue);
|
||||
if (char && index < length - 1) focusInput(index + 1);
|
||||
if (newValue.length === length && !newValue.includes("")) onComplete?.(newValue);
|
||||
if (newValue.length === length) onComplete?.(newValue);
|
||||
},
|
||||
[digits, length, onChange, onComplete, focusInput]
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user