[PM-10024] Force focus on Master Password or Pin input field (#3601)

This commit is contained in:
A. Bubnov 2024-08-07 18:34:32 +03:00 committed by GitHub
parent 23066769a1
commit 22dae88b42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 0 deletions

View file

@ -196,6 +196,7 @@ fun VaultUnlockScreen(
.testTag(state.vaultUnlockType.unlockScreenInputTestTag)
.padding(horizontal = 16.dp)
.fillMaxWidth(),
autoFocus = state.showKeyboard,
)
Spacer(modifier = Modifier.height(24.dp))
Text(

View file

@ -354,6 +354,11 @@ data class VaultUnlockState(
*/
val showBiometricLogin: Boolean get() = isBiometricEnabled && isBiometricsValid
/**
* Indicates if we want force focus on Master Password \ PIN input field and show keyboard.
*/
val showKeyboard: Boolean get() = !showBiometricLogin && !hideInput
/**
* Represents the various dialogs the vault unlock screen can display.
*/

View file

@ -2,6 +2,7 @@ package com.x8bit.bitwarden.ui.auth.feature.vaultunlock
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsEnabled
import androidx.compose.ui.test.assertIsFocused
import androidx.compose.ui.test.assertIsNotEnabled
import androidx.compose.ui.test.filterToOne
import androidx.compose.ui.test.hasAnyAncestor
@ -417,6 +418,15 @@ class VaultUnlockScreenTest : BaseComposeTest() {
verify { viewModel.trySendAction(VaultUnlockAction.UnlockClick) }
}
@Test
fun `state with input and without biometrics should request focus on input field`() {
mutableStateFlow.update { it.copy(hideInput = false, isBiometricEnabled = false) }
composeTestRule
.onNodeWithText("Master password")
.performScrollTo()
.assertIsFocused()
}
@Test
fun `input change should send InputChanged action`() {
val input = "abcd1234"