From 563cb21dbd3f0bc62354404e01c5b4862444a661 Mon Sep 17 00:00:00 2001 From: Oluwatobi Shokunbi Date: Thu, 23 Jul 2026 15:26:16 +0100 Subject: [PATCH 1/2] fix(auth): handle system back press in phone auth flow Fixes #2058 by adding BackHandler to the default phone auth UI so the system back button behaves consistently with the UI back arrow. On the phone number entry screen, back navigates to the method picker (or does nothing when phone is the only provider). On the verification code screen, back returns to the phone number entry step. Users with custom phoneContent slots can add their own BackHandler for full control. --- .../com/firebase/ui/auth/ui/screens/phone/PhoneAuthScreen.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/auth/src/main/java/com/firebase/ui/auth/ui/screens/phone/PhoneAuthScreen.kt b/auth/src/main/java/com/firebase/ui/auth/ui/screens/phone/PhoneAuthScreen.kt index e317c639d..804bbd574 100644 --- a/auth/src/main/java/com/firebase/ui/auth/ui/screens/phone/PhoneAuthScreen.kt +++ b/auth/src/main/java/com/firebase/ui/auth/ui/screens/phone/PhoneAuthScreen.kt @@ -16,6 +16,7 @@ package com.firebase.ui.auth.ui.screens.phone import android.content.Context import android.util.Log +import androidx.activity.compose.BackHandler import androidx.activity.compose.LocalActivity import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -359,6 +360,7 @@ private fun DefaultPhoneAuthContent( ) { when (state.step) { PhoneAuthStep.EnterPhoneNumber -> { + BackHandler { onCancel() } EnterPhoneNumberUI( configuration = configuration, isLoading = state.isLoading, @@ -372,6 +374,7 @@ private fun DefaultPhoneAuthContent( } PhoneAuthStep.EnterVerificationCode -> { + BackHandler { state.onChangeNumberClick() } EnterVerificationCodeUI( configuration = configuration, isLoading = state.isLoading, From 16be59246650cc390eb6c47fc67b5ea2f61e010e Mon Sep 17 00:00:00 2001 From: Oluwatobi Shokunbi Date: Thu, 23 Jul 2026 16:02:42 +0100 Subject: [PATCH 2/2] fix(auth): handle system back press in phone auth flow Fixes #2058 by adding BackHandler to PhoneAuthScreen so the system back button is handled consistently for both default and custom phone content. The base handler delegates to onCancel (navigating to the method picker or preventing premature activity finish in phone-only flows). The default UI adds a step-specific override on the verification code screen to return to phone number entry. Custom phoneContent slots inherit the base behavior and can override with their own BackHandler. --- .../com/firebase/ui/auth/ui/screens/phone/PhoneAuthScreen.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/auth/src/main/java/com/firebase/ui/auth/ui/screens/phone/PhoneAuthScreen.kt b/auth/src/main/java/com/firebase/ui/auth/ui/screens/phone/PhoneAuthScreen.kt index 804bbd574..3534148bf 100644 --- a/auth/src/main/java/com/firebase/ui/auth/ui/screens/phone/PhoneAuthScreen.kt +++ b/auth/src/main/java/com/firebase/ui/auth/ui/screens/phone/PhoneAuthScreen.kt @@ -341,6 +341,8 @@ fun PhoneAuthScreen( } ) + BackHandler { onCancel() } + if (content != null) { content(state) } else { @@ -360,7 +362,6 @@ private fun DefaultPhoneAuthContent( ) { when (state.step) { PhoneAuthStep.EnterPhoneNumber -> { - BackHandler { onCancel() } EnterPhoneNumberUI( configuration = configuration, isLoading = state.isLoading,