fix(auth): pre-fill email when "Continue as" button is tapped (#2423) - #2425
fix(auth): pre-fill email when "Continue as" button is tapped (#2423)#2425just1and0 wants to merge 5 commits into
Conversation
The "Continue as..." button displayed the saved identifier but discarded it on click, sending the user to a blank email form. Add an onContinueAsSelected callback to AuthMethodPicker that carries the identifier through to EmailAuthScreen, which now initializes the email field with the saved address.
There was a problem hiding this comment.
Code Review
This pull request introduces the ability to pre-fill the email address on the email authentication screen when a user selects the "Continue as..." option from the method picker. This is achieved by passing the saved identifier from AuthMethodPicker via a new onContinueAsSelected callback, storing it in a prefillEmail state in FirebaseAuthScreen, and passing it to EmailAuthScreen to initialize the email input field. Feedback on the changes highlights a potential issue where a non-email identifier (like a phone number) could incorrectly pre-fill the email field if the last used provider was not Email. A code suggestion is provided to only set prefillEmail when the provider is AuthProvider.Email.
demolaf
left a comment
There was a problem hiding this comment.
LGTM, just a couple of changes.
| val mode = rememberSaveable { mutableStateOf(initialMode) } | ||
| val displayNameValue = rememberSaveable { mutableStateOf("") } | ||
| val emailTextValue = rememberSaveable { mutableStateOf("") } | ||
| val emailTextValue = rememberSaveable { mutableStateOf(prefillEmail ?: "") } |
There was a problem hiding this comment.
we can add a unit test that asserts the email is pre-filled. there's already a SignUpUITest.kt.
There was a problem hiding this comment.
Added SignInUITest.kt with two tests: one asserts the email field is pre-filled when an initial value is provided, and another asserts it's empty when no value is given. Followed the same pattern as SignUpUITest.kt.
There was a problem hiding this comment.
@just1and0 this doesn't test from AuthMethodPicker, I was thinking a test that passes lastSignInPreference (via SignInPreferenceManager.SignInPreference) to render the button, clicks "ContinueAsButton", and asserts onContinueAsSelected fires with the right (provider, identifier)?
- Update kDoc to say "email address" instead of "phone number" since phone pre-fill is not wired up in this PR - Add SignInUITest with assertions for email pre-fill behavior
Summary
AuthMethodPickerdisplayed the saved email/identifier but discarded it on click — the user landed on a blank email form identical to tapping the regular provider button.onContinueAsSelectedcallback toAuthMethodPickerthat carries the saved identifier through toEmailAuthScreen, which now pre-fills the email field with the saved address.Fixes #2423
My.Movie.2.mp4
Test plan
customLayoutstill work (they don't receiveonContinueAsSelected)