Hi all, so we have a screen that has a material sc...
# compose
m
Hi all, so we have a screen that has a material scaffold in it with optional back and close buttons (for full screen takeovers). When the screen appears and talkback is on, the close button is automatically getting focused and announced. What we really want is to have the header text focused and announced instead. We don't really want to change the traversal order though, we just want to move focus to the header. The problem i'm having is that in order to use FocusManager i have to put an arbitrary delay before i try to move the focus, and i can't specifically ask a specific node for focus. When i tried using FocusRequester itself, it did nothing. [Code is in thread]
Copy code
@OptIn(ExperimentalMaterial3Api::class)
@Preview
@Composable
fun ScaffoldFocusTest() {
    Scaffold(
        topBar = {
            TopAppBar(
                title = { },
                actions = {
                    IconButton(onClick = {}) {
                        Icon(imageVector = Icons.Default.Close, contentDescription = "Close")
                    }
                }
            )
        }
    ) {
        Column(modifier = Modifier.padding(it)) {
            Text(
                modifier = Modifier
                    .semantics {
                        heading()
                    }.focusable(true),
                text = "Heading",
                style = MaterialTheme.typography.headlineLarge
            )

        }
    }

    val focusManager = LocalFocusManager.current
    LaunchedEffect(true) {
        delay(1000L)
        focusManager.moveFocus(FocusDirection.Down)
    }
}