Merged in fix/SW-1695-clear-otp-password-on-error (pull request #1375)

Clear and focus OTP input on error

Approved-by: Joakim Jäderberg
This commit is contained in:
Anton Gunnarsson
2025-02-20 07:29:36 +00:00
parent 7b15687f07
commit e75c714148

View File

@@ -100,6 +100,7 @@ export default function OneTimePasswordForm({
function handleOTPEntered(otp: string) { function handleOTPEntered(otp: string) {
startTransition(async () => { startTransition(async () => {
const redirectRes = await onSubmit({ otp }) const redirectRes = await onSubmit({ otp })
setOtp("")
if (redirectRes.type === "replace") { if (redirectRes.type === "replace") {
router.replace(redirectRes.url) router.replace(redirectRes.url)
return return
@@ -146,6 +147,7 @@ export default function OneTimePasswordForm({
</div> </div>
<OTPInput <OTPInput
autoFocus
value={otp} value={otp}
onChange={setOtp} onChange={setOtp}
maxLength={otpLength} maxLength={otpLength}