From d6afee11bc252c34d37cdb729c3e7afca98cbcaf Mon Sep 17 00:00:00 2001 From: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com> Date: Thu, 25 Jan 2024 21:50:53 +0700 Subject: [PATCH] desktop: prevent clicking enter on alert and text field at the same time (#3714) --- .../kotlin/chat/simplex/common/views/helpers/AlertManager.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/helpers/AlertManager.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/helpers/AlertManager.kt index 082d733205..a4cea68ff2 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/helpers/AlertManager.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/helpers/AlertManager.kt @@ -22,6 +22,7 @@ import chat.simplex.common.ui.theme.* import chat.simplex.res.MR import dev.icerock.moko.resources.StringResource import dev.icerock.moko.resources.compose.painterResource +import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableStateFlow class AlertManager { @@ -128,6 +129,8 @@ class AlertManager { ) { val focusRequester = remember { FocusRequester() } LaunchedEffect(Unit) { + // Wait before focusing to prevent auto-confirming if a user used Enter key on hardware keyboard + delay(200) focusRequester.requestFocus() } TextButton(onClick = { @@ -195,6 +198,8 @@ class AlertManager { AlertContent(text, hostDevice, extraPadding = true) { val focusRequester = remember { FocusRequester() } LaunchedEffect(Unit) { + // Wait before focusing to prevent auto-confirming if a user used Enter key on hardware keyboard + delay(200) focusRequester.requestFocus() } Row(