From 73ccae24252943b8d70d8150bf45cb3038d8c68d Mon Sep 17 00:00:00 2001 From: DeathKhan Date: Sun, 15 Nov 2026 08:35:49 -0600 Subject: [PATCH] fix(apps): focus the folder when arrows follow a touch (#2545) Opening a folder by touch and then pressing an arrow left the highlight on the page behind: focus starts outside the page, so the folder's first request was turned to the page's own entry tile. The folder now keeps asking until focus is inside it. --- .../main/java/com/droiddeck/launcher/ui/AndroidAppsPage.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/AndroidAppsPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/AndroidAppsPage.kt index bc115b382d..4303dde0fe 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/AndroidAppsPage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/AndroidAppsPage.kt @@ -852,11 +852,13 @@ private fun FolderSheet( val ff = LocalFrontFocus.current val grid = rememberLazyGridState() var closing by remember { mutableStateOf(false) } + var inside by remember { mutableStateOf(false) } LaunchedEffect(renaming, inputMode) { if (!renaming && !closing && inputMode == InputMode.Keyboard && apps.isNotEmpty()) { grid.scrollToItem(0) - repeat(2) { androidx.compose.runtime.withFrameNanos { } } - if (!closing) runCatching { firstApp.requestFocus() } + androidx.compose.runtime.withFrameNanos { } + // After touch, focus starts outside the page and the first request is turned to the page's own entry, behind the sheet. Ask until it is in here. + focusWithinFrames({ inside || closing }) { firstApp } } } val close = { @@ -884,6 +886,7 @@ private fun FolderSheet( .glideBorder(false, Shape16, pal.signal, pal.signal.copy(alpha = 0.22f)) .pointerInput(Unit) { awaitEachGesture { awaitFirstDown(requireUnconsumed = false).consume() } } .controllerBack(close) + .onFocusChanged { inside = it.hasFocus } .focusProperties { exit = { dir -> if (dir == FocusDirection.Up || dir == FocusDirection.Down || dir == FocusDirection.Left || dir == FocusDirection.Right) FocusRequester.Cancel