Hello I have a simple compose layout with bottom N...
# compose
g
Hello I have a simple compose layout with bottom NavigationBar and main content. When talkback is on, how can the focus go directly to the main content when the bottom nav item is selected? See the code in 🧵 I've tried adding a focus requester and requesting the focus but I've read that is not the same as talkback focus. I know there is no direct way to set talkback focus so I'm unclear how to do this. Or is this the expected behaviour and talkback users would know to swipe to get the the content? To me it would make sense if the focus changes automatically but there does not seem to be a way to accomplish this.
Copy code
@Composable
private fun Example() {
    var selectedBottomBar by remember { mutableIntStateOf(0) }
    val focusRequester = remember { FocusRequester() }
    Scaffold(
        modifier = Modifier.fillMaxSize(),
        bottomBar = {
            NavigationBar {
                for (index in 0..2) {
                    val text = "Home $index"
                    NavigationBarItem(
                        label = { Text(text) },
                        icon = { Icon(Icons.Default.Home, text) },
                        selected = selectedBottomBar == index,
                        onClick = {
                            selectedBottomBar = index
                            focusRequester.requestFocus()
                        }
                    )
                }
            }
        }
    ) { innerPadding ->
        Text(
            text = "Hello $selectedBottomBar!",
            modifier = Modifier
                .fillMaxSize()
                .padding(innerPadding)
                .focusRequester(focusRequester)
        )
    }
}
This is very heavily simplified version of a real app.
c
FocusRequester works just fine for talkback
g
It's my experience that it does not work all the time. In the code snippet above, could you suggest what is wrong?