LOGIN-FOCUS: passwordless focuses email first, captcha only when email present#117
Merged
Conversation
… email present When switching to Passwordless sign-in, CodeCaptcha's mount effect grabbed focus unconditionally (it ran after the email input's autoFocus), so the cursor landed in the captcha even with an empty email. Make the captcha's focus-on-mount opt-in (autoFocus prop, default true to preserve every other caller) and let Signin pick the target via a pure, unit-tested helper: email field when no email entered yet, captcha when an email is already present. - packages/web/src/lib/loginFocus.ts (+ tests, 6/6): magicLinkFocusTarget / hasEnteredEmail - CodeCaptcha: autoFocus prop gates the focus effect - Signin: email ref + on-mode-entry focus effect; captcha autoFocus only when email present - tests/e2e/login-focus.spec.ts (@loginfocus, 2/2 live): empty→email, present→captcha Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🧪 Comprehensive Test Suite
Full-stack smoke gate runs in the CI workflow. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the passwordless-login focus order reported while dogfooding the live login page.
Bug: switching to the Passwordless tab put the cursor in the CAPTCHA, not the email field.
CodeCaptchafocused its own input on mount unconditionally, and that effect ran after the email input'sautoFocus, stealing focus.Fix:
CodeCaptchagets anautoFocusprop (defaulttrue, so every other caller is unchanged); the focus-on-mount effect is gated on it.lib/loginFocus.ts) decides the target: email field when no email entered yet, captcha when an email is already present, nothing while inactive / after the link is sent.Signinfocuses the email field on entering passwordless mode and passesautoFocusto the captcha only when an email is present.Tests:
loginFocus6/6 unit ·tests/e2e/login-focus.spec.ts2/2 live (empty→email, present→captcha) · web typecheck clean.🤖 Generated with Claude Code