app: keep dpad focus in content on rail

With a navigation rail there is nothing below the page, yet pressing
DPAD_DOWN on the last focusable item let the 2D focus search leave
the page and land on a rail item to the side. Cancel downward exits
from the page in rail mode; moving to the rail is still possible
with DPAD_LEFT. The bottom bar keeps its existing focus handling.

Assisted-by: Claude Opus 5.5
This commit is contained in:
topjohnwu
2026-10-08 10:35:49 -07:00
committed by John Wu
parent a271b9559e
commit b9d7d6f2d1
@@ -222,9 +222,12 @@ fun MainScreen(
}
}
onExit = {
if (requestedFocusDirection == FocusDirection.Up || (isBar &&
(requestedFocusDirection == FocusDirection.Left ||
requestedFocusDirection == FocusDirection.Right))
// With a rail, nothing is below the page, so don't let DPAD_DOWN
// jump into the rail; leaving to the rail is done with DPAD_LEFT.
val dir = requestedFocusDirection
if (dir == FocusDirection.Up ||
(!isBar && dir == FocusDirection.Down) ||
(isBar && (dir == FocusDirection.Left || dir == FocusDirection.Right))
) {
cancelFocusChange()
}