From 80f31cdff92fda433e0f002bc0811a0d9f484352 Mon Sep 17 00:00:00 2001 From: Dave Severns <149429124+dseverns-livefront@users.noreply.github.com> Date: Tue, 7 Jan 2025 09:52:12 -0500 Subject: [PATCH] PM-16474 Adding custom field issues when another text field holds focus (#4511) --- .../feature/addedit/VaultAddEditCustomFieldsButton.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/addedit/VaultAddEditCustomFieldsButton.kt b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/addedit/VaultAddEditCustomFieldsButton.kt index fcf68e22851..8d414b5b826 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/addedit/VaultAddEditCustomFieldsButton.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/addedit/VaultAddEditCustomFieldsButton.kt @@ -6,6 +6,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.stringResource import com.x8bit.bitwarden.R @@ -71,10 +72,14 @@ fun VaultAddEditCustomFieldsButton( }, ) } - + val focusManager = LocalFocusManager.current BitwardenOutlinedButton( label = stringResource(id = R.string.new_custom_field), - onClick = { shouldShowChooserDialog = true }, + onClick = { + // Clear any current focused item such as an unrelated text field. + focusManager.clearFocus() + shouldShowChooserDialog = true + }, modifier = modifier.testTag("NewCustomFieldButton"), ) }