mirror of
https://github.com/bitwarden/android.git
synced 2024-11-29 06:18:52 +03:00
Clear focus whenever the root navigation changes (#1411)
This commit is contained in:
parent
9b30d50eac
commit
5329629e22
1 changed files with 6 additions and 0 deletions
|
@ -1,10 +1,12 @@
|
|||
package com.x8bit.bitwarden.ui.platform.feature.rootnav
|
||||
|
||||
import android.app.Activity
|
||||
import androidx.compose.animation.AnimatedContentTransitionScope
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.navigation.NavBackStackEntry
|
||||
|
@ -117,6 +119,10 @@ fun RootNavScreen(
|
|||
}
|
||||
previousStateReference.set(state)
|
||||
|
||||
// In some scenarios on an emulator the Activity can leak when recreated
|
||||
// if we don't first clear focus anytime we change the root destination.
|
||||
(LocalContext.current as? Activity)?.currentFocus?.clearFocus()
|
||||
|
||||
// When state changes, navigate to different root navigation state
|
||||
val rootNavOptions = navOptions {
|
||||
// When changing root navigation state, pop everything else off the back stack:
|
||||
|
|
Loading…
Reference in a new issue