From 9c729c936945919ffa7d5bfb5934519c9ab24faf Mon Sep 17 00:00:00 2001 From: denis0001-dev Date: Wed, 14 Oct 2026 15:52:49 +0300 Subject: [PATCH] Chat list selection mode fix, part 2 Signed-off-by: denis0001-dev --- .../kotlin/ru/fromchat/ui/main/MainScreen.kt | 1 + .../fromchat/ui/main/chats/ChatListShared.kt | 20 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/shared/src/commonMain/kotlin/ru/fromchat/ui/main/MainScreen.kt b/app/shared/src/commonMain/kotlin/ru/fromchat/ui/main/MainScreen.kt index 6423d59..1a47acf 100644 --- a/app/shared/src/commonMain/kotlin/ru/fromchat/ui/main/MainScreen.kt +++ b/app/shared/src/commonMain/kotlin/ru/fromchat/ui/main/MainScreen.kt @@ -277,6 +277,7 @@ fun MainScreen( Box( modifier = Modifier .fillMaxSize() + .background(MaterialTheme.colorScheme.surface) .hazeSource(contextMenuHazeState), ) { Scaffold( diff --git a/app/shared/src/commonMain/kotlin/ru/fromchat/ui/main/chats/ChatListShared.kt b/app/shared/src/commonMain/kotlin/ru/fromchat/ui/main/chats/ChatListShared.kt index 1fd3bf7..e90564c 100644 --- a/app/shared/src/commonMain/kotlin/ru/fromchat/ui/main/chats/ChatListShared.kt +++ b/app/shared/src/commonMain/kotlin/ru/fromchat/ui/main/chats/ChatListShared.kt @@ -148,6 +148,7 @@ private val ChatListCategoryMargin = PaddingValues( * Mouse secondary click opens the one-chat context menu (same flow as avatar long-press). * Mouse primary long-press does not enter selection. */ +@Composable @OptIn(ExperimentalFoundationApi::class) private fun Modifier.chatRowOpenAndSelectGestures( selectionEnabled: Boolean, @@ -156,11 +157,22 @@ private fun Modifier.chatRowOpenAndSelectGestures( onOpen: () -> Unit, onEnterSelection: () -> Unit, onMouseContextMenu: (localOffset: Offset) -> Unit, -): Modifier = - combinedClickable( +): Modifier { + // combinedClickable fires onClick on the up of the very gesture that just triggered the + // selection long-press; onOpen must be skipped there, mirroring combinedClickable's + // built-in post-longClick click suppression (in selection mode onOpen toggles + // selection, so an un-suppressed click reverts the mode right after entering). + val suppressNextClick = remember { mutableStateOf(false) } + return combinedClickable( interactionSource = interactionSource, indication = ripple(), - onClick = onOpen, + onClick = { + if (suppressNextClick.value) { + suppressNextClick.value = false + } else { + onOpen() + } + }, ).pointerInput(selectionEnabled) { if (!selectionEnabled) return@pointerInput awaitEachGesture { @@ -186,6 +198,7 @@ private fun Modifier.chatRowOpenAndSelectGestures( // Atomic: the entering coroutine dies with this gesture, but the // state flip must complete in one step — otherwise an early release // sees an empty selection and exits before the enter animation begins. + suppressNextClick.value = true scope.launch { onEnterSelection() } waitForUpOrCancellation() } @@ -194,6 +207,7 @@ private fun Modifier.chatRowOpenAndSelectGestures( } } } +} /** * Touch/stylus: press feedback + long-press opens the menu.