drawer: open focused on the current destination
Opening the menu landed focus on Home regardless of where the user was; the sensible start is the item that already carries the selected state. From there all other destinations are a D-pad step or two away.
This commit is contained in:
parent
6d1cc8986a
commit
44a39b83e9
1 changed files with 4 additions and 2 deletions
|
|
@ -382,6 +382,8 @@ private fun MenuDrawer(
|
|||
onDismiss: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
// Focus the destination we are on (issue #16); its item carries the red
|
||||
// selected background. The first drawer item (Home) was the wrong target.
|
||||
val drawerFocus = remember { FocusRequester() }
|
||||
LaunchedEffect(Unit) { runCatching { drawerFocus.requestFocus() } }
|
||||
val signOutContext = androidx.compose.ui.platform.LocalContext.current
|
||||
|
|
@ -405,13 +407,13 @@ private fun MenuDrawer(
|
|||
} else false
|
||||
},
|
||||
) {
|
||||
Destination.entries.forEachIndexed { index, dest ->
|
||||
Destination.entries.forEach { dest ->
|
||||
MenuDrawerItem(
|
||||
icon = dest.icon(),
|
||||
label = dest.title,
|
||||
selected = dest == selected,
|
||||
onClick = { onSelect(dest) },
|
||||
modifier = if (index == 0) Modifier.focusRequester(drawerFocus) else Modifier,
|
||||
modifier = if (dest == selected) Modifier.focusRequester(drawerFocus) else Modifier,
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue