From 58c8bb43c88a8541ff8c53434d72def493db4ef8 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 12 Feb 2024 15:20:28 +0100 Subject: [PATCH] Open the keyboard (and keep it opened) when creating a poll. Actually replace a Disposable effect by a action to close the keyboard in the `onBackPressed` callback. --- changelog.d/2329.bugfix | 1 + .../features/messages/impl/MessagesView.kt | 16 ++++++---------- 2 files changed, 7 insertions(+), 10 deletions(-) create mode 100644 changelog.d/2329.bugfix diff --git a/changelog.d/2329.bugfix b/changelog.d/2329.bugfix new file mode 100644 index 0000000000..68d4b53615 --- /dev/null +++ b/changelog.d/2329.bugfix @@ -0,0 +1 @@ +Open the keyboard (and keep it opened) when creating a poll. diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesView.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesView.kt index d0fecc8575..a7bfbdd0f9 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesView.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesView.kt @@ -39,7 +39,6 @@ import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable -import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf @@ -194,7 +193,12 @@ fun MessagesView( roomName = state.roomName.dataOrNull(), roomAvatar = state.roomAvatar.dataOrNull(), callState = state.callState, - onBackPressed = onBackPressed, + onBackPressed = { + // Since the textfield is now based on an Android view, this is no longer done automatically. + // We need to hide the keyboard when navigating out of this screen. + localView.hideKeyboard() + onBackPressed() + }, onRoomDetailsClicked = onRoomDetailsClicked, onJoinCallClicked = onJoinCallClicked, ) @@ -260,14 +264,6 @@ fun MessagesView( onUserDataClicked = onUserDataClicked, ) ReinviteDialog(state = state) - - // Since the textfield is now based on an Android view, this is no longer done automatically. - // We need to hide the keyboard automatically when navigating out of this screen. - DisposableEffect(Unit) { - onDispose { - localView.hideKeyboard() - } - } } @Composable