Is it actually possible to control focus order for...
# compose
l
Is it actually possible to control focus order for accessibility? I have not been able to get it to work following a few different google recommendations.
How about something like this:
Copy code
Row(
    modifier = Modifier.clickable { ... },
) {
    Column { 
        // I should be first
        Text(
            modifier = Modifier,
        )
        // I should be third
        Text(
            modifier = Modifier,
        )
   }
    // I should be second
    Text(
        modifier = Modifier,
    )
}
How could I make this happen?
This doesn’t work. The clickable seems to clear the ordering.
Copy code
val (first, second, third) = remember { FocusRequester.createRefs() }

Row(
    modifier = Modifier.clickable { ... },
) {
    Column { 
        // I should be first
        Text(
            modifier = Modifier.focusRequester(first),
        )
        // I should be third
        Text(
            modifier = Modifier.focusRequester(third),
        )
   }
    // I should be second
    Text(
        modifier = Modifier.focusRequester(second),
    )
}
my suspicion is that because
Modifier.clickable
uses
Modifier.semantics(mergeDescendants = true) {…}
all of the ordering stuff I am setting is lost.
so I if I want to maintain some order I will need to build a content description for the
clickable
s
I remember reading something in the docs about focus order https://developer.android.com/jetpack/compose/touch-input/focus#default-focus, which in turn links to a bug report about some things that may not be possible atm, not sure https://issuetracker.google.com/issues/186443263. Maybe this helps you
l
Thanks! looks like I will just jump out a window
s
That's an odd solution to this problem
l
I live on the bottom floor and it is nice outside
s
I changed my mind, that's an amazing solution to this problem
l
🤝
100 Views