fix(launcher): LT and RT keep the focus ring on the tab rail (#3039)

* fix(launcher): LT and RT keep the focus ring on the tab rail

A trigger step selected the tab like a tap on the rail, which also sent focus into the new page, and each page put it somewhere different. The step now shows the page and focuses its rail item, and for a second puts focus back on the rail if the page takes it, until another key is pressed. Dual screens, which have no rail on the main screen, keep focusing the page.

* fix(launcher): end the trigger step's rail hold when another navigation changes the page

A navigation that changed the selected page during the hold, such as opening a game from a link, was undone: the hold focused the stepped tab's rail item, and that focus switched the page back. The hold now stops as soon as the selection is no longer the one the step made.

* fix(launcher): end the trigger step's rail hold when another navigation opens a page

Opening the Components page does not change the selected tab, so a navigation there during the hold kept it running and the hold could pull focus from Components back to the rail. The hold now also tracks the page key: once the page its own step opened is showing, any other page ends the hold.

---------

Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
This commit is contained in:
Tushar GandheandKurt Himebauch authored and GitHub committed 2026-11-24 18:13:10 -05:00
1 parent 7bf75af8a1
commit af1fe6c61c
2 files changed
+25 -1

No files matched your search

@@ -2170,6 +2170,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
if (!triggerKeys.synthesizing && triggerKeys.nativeKey(event)) return true
val tabStep = com.droiddeck.launcher.ui.dualPageStep(event)
val tabs = com.droiddeck.launcher.ui.MainTabSteps.handler
if (tabStep == null && event.action == KeyEvent.ACTION_DOWN) com.droiddeck.launcher.ui.MainTabSteps.otherKeys++
if (tabStep != null && tabs != null) {
if (controllerHaptics) com.droiddeck.launcher.ui.ControllerHaptics.onKey(this, event)
if (event.action == KeyEvent.ACTION_DOWN && event.repeatCount == 0) tabs(tabStep)
@@ -58,6 +58,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.snapshotFlow
import androidx.compose.runtime.withFrameNanos
import kotlinx.coroutines.launch
import kotlinx.coroutines.flow.first
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
@@ -764,12 +765,31 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com
focusManager.clearFocus(force = true)
onRailSelect(key)
}, a)
val stepScope = androidx.compose.runtime.rememberCoroutineScope()
val pageKeyNow = androidx.compose.runtime.rememberUpdatedState(s.pageKey)
var railHold by remember { mutableStateOf<kotlinx.coroutines.Job?>(null) }
val tabStep = androidx.compose.runtime.rememberUpdatedState { step: Int ->
if (!processSettingsPageVisible) {
val keys = navigationKeys(s)
keys.getOrNull(keys.indexOf(railSelectionNow.value) + step)?.let { key ->
PageSwipe.direction = step
onRailSelect(key)
if (s.dualScreen) { onRailSelect(key); return@let }
showRailPage(key, false)
if (inputModeManager.inputMode != InputMode.Keyboard) inputModeManager.requestInputMode(InputMode.Keyboard)
val since = MainTabSteps.otherKeys
val owner = selected
val ownPage = if (key == "components") "components" else null
railHold?.cancel()
// Pages focus their own first control as they appear; the ring stays on the rail until another key moves it.
railHold = stepScope.launch {
var pageShown = false
repeat(RAIL_HOLD_FRAMES) {
withFrameNanos { }
if (MainTabSteps.otherKeys != since || selected != owner) return@launch
if (pageKeyNow.value == ownPage) pageShown = true else if (pageShown) return@launch
if (frontFocus.focusedRail != key) runCatching { frontFocus.railFor(key).requestFocus() }
}
}
}
}
}
@@ -900,4 +920,7 @@ internal object ChildProcessSetup {
internal object MainTabSteps {
@Volatile var handler: ((Int) -> Unit)? = null
@Volatile var otherKeys = 0
}
private const val RAIL_HOLD_FRAMES = 60