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.
This commit is contained in:
DeathKhan authored and GitHub committed 2026-11-15 09:35:49 -05:00
1 parent 6384b220fc
commit 73ccae2425
1 file changed
+5 -2
@@ -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