diff --git a/app/src/main/java/com/vultisig/wallet/ui/components/library/form/Form.kt b/app/src/main/java/com/vultisig/wallet/ui/components/library/form/Form.kt index 57ef36906..fbd58e7b6 100644 --- a/app/src/main/java/com/vultisig/wallet/ui/components/library/form/Form.kt +++ b/app/src/main/java/com/vultisig/wallet/ui/components/library/form/Form.kt @@ -62,7 +62,6 @@ import com.vultisig.wallet.ui.theme.Theme import com.vultisig.wallet.ui.theme.cursorBrush import com.vultisig.wallet.ui.utils.UiText import com.vultisig.wallet.ui.utils.asString -import com.vultisig.wallet.ui.utils.clearFocusOnKeyboardDismiss @Composable @@ -309,9 +308,8 @@ internal fun BasicFormTextField( focusManager.clearFocus() }, modifier = modifier - .clearFocusOnKeyboardDismiss() - .onFocusEvent { - if (isFocused != it.isFocused) { + .onFocusEvent { + if (isFocused != it.isFocused ) { isFocused = it.isFocused if (!isFocused) { onLostFocus() diff --git a/app/src/main/java/com/vultisig/wallet/ui/utils/Keyboard.kt b/app/src/main/java/com/vultisig/wallet/ui/utils/Keyboard.kt deleted file mode 100644 index 6df9232ca..000000000 --- a/app/src/main/java/com/vultisig/wallet/ui/utils/Keyboard.kt +++ /dev/null @@ -1,42 +0,0 @@ -package com.vultisig.wallet.ui.utils - -import androidx.compose.foundation.layout.ExperimentalLayoutApi -import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.isImeVisible -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.composed -import androidx.compose.ui.focus.onFocusEvent -import androidx.compose.ui.platform.LocalFocusManager - -// TODO this is a hack, because BasicTextField2 -// seems to have issues with refocusing after keyboard dismiss -// we should remove this at some point in future after Compose update -@OptIn(ExperimentalLayoutApi::class) -fun Modifier.clearFocusOnKeyboardDismiss(): Modifier = composed { - var isFocused by remember { mutableStateOf(false) } - var keyboardAppearedSinceLastFocused by remember { mutableStateOf(false) } - if (isFocused) { - val imeIsVisible = WindowInsets.isImeVisible - val focusManager = LocalFocusManager.current - LaunchedEffect(imeIsVisible) { - if (imeIsVisible) { - keyboardAppearedSinceLastFocused = true - } else if (keyboardAppearedSinceLastFocused) { - focusManager.clearFocus() - } - } - } - onFocusEvent { - if (isFocused != it.isFocused) { - isFocused = it.isFocused - if (isFocused) { - keyboardAppearedSinceLastFocused = false - } - } - } -} \ No newline at end of file