# Focus Bug Reproduction Recipes

## Bug A: Stuck in one row (can't move UP/DOWN)

**User report:** "I can only go to the first catalog row right under the filters and to the right. If I try to go up nothing happens."

**Root cause:** 
1. `focusProperties { up = FocusRequester.Cancel; down = FocusRequester.Cancel }` on every card
2. Row `Column` wrappers had no `Modifier.focusable()` — LazyColumn items had no focusable anchor

**Trigger code:**
```kotlin
// BROKEN
FocusCatalogCard(
    links = FocusLinks(
        up = FocusRequester.Cancel,   // BLOCKS vertical!
        down = FocusRequester.Cancel, // BLOCKS vertical!
        left = prevRequester ?: FocusRequester.Cancel,
        right = nextRequester ?: FocusRequester.Cancel,
    ),
)

// Also broken: row Column without focusable
Column(modifier = Modifier.padding(bottom = 24.dp)) { // no .focusable()
```

**Fix:**
```kotlin
// FIXED
PremiumContentCard(
    links = FocusLinks(), // all null = Compose auto-determines
)

Column(modifier = Modifier.padding(bottom = 24.dp).focusable()) { // anchor added
```

**Files changed:** UnspooledHomeScreen.kt, CatalogBrowserScreen.kt

## Bug B: LEFT jumps to sidebar (instead of left card)

**User report:** "If I try to go left it jumps to the sidebar, doesn't let me go to the movie to the left."

**Root cause:** `UnifiedChromeScaffold` content area had `onKeyEvent` intercepting ANY LEFT press:
```kotlin
// BROKEN
.onKeyEvent { keyEvent ->
    if (keyEvent.type == KeyEventType.KeyDown && keyEvent.key == Key.DirectionLeft) {
        sidebarExpanded = true
        runCatching { sidebarEntryRequester.requestFocus() }
        true  // CONSUMES the LEFT event — steals from card navigation
    } else false
}
```

**Fix:** Removed LEFT key interception entirely. Sidebar now entered via BACK key only:
```kotlin
// FIXED — no onKeyEvent for LEFT on content area
Box(modifier = Modifier.weight(1f).fillMaxHeight()) { content() }

BackHandler(enabled = !sidebarExpanded) {
    sidebarExpanded = true
    onFocusZoneChanged(FocusZone.Sidebar)
}
```

## Bug C: Sidebar opens but can't focus items

**User report:** "It doesn't even select the sidebar, it just opens it."

**Root cause:** BackHandler expanded sidebar but `sidebarEntryRequester` was on the outer `Box` wrapper — focus never transferred to sidebar items. Also had guard condition `BackHandler(enabled = !sidebarExpanded && contentHasFocus)` that prevented firing.

**Fix:** Added `LaunchedEffect(sidebarExpanded)` that requests focus on the selected sidebar item after expansion animation settles. Removed `contentHasFocus` guard.
```kotlin
LaunchedEffect(sidebarExpanded) {
    if (sidebarExpanded) {
        delay(100) // let width animation settle
        val selectedKey = items.find { it.route == selectedRoute }?.key
        sidebarRequesters[selectedKey]?.requestFocus()
            ?: sidebarRequesters.values.firstOrNull()?.requestFocus()
    }
}
```

## Bug D: runBlocking on main thread

**Symptom:** Laggy, janky behavior.
**Root cause:** `runBlocking { delay(150) }` in RIGHT key handler on main thread.
**Fix:** Removed — content focus transfer happens naturally after recomposition when sidebar collapses.
