At some point in the past couple of releases, this...
# compose-web
r
At some point in the past couple of releases, this modifier started giving me issues on web:
Copy code
fun Modifier.nextFocusOnTab(requester: () -> FocusRequester?): Modifier {
    return onPreviewKeyEvent { event ->
        if (event.key == Key.Tab && event.type == KeyEventType.KeyDown) {
            requester()?.requestFocus()
            true
        } else {
            false
        }
    }
}
It switches the focus to the
requester
(for example, the next input receives the caret) but actually the focus is requested by the browser's address bar, so the tab button becomes unusable. A few versions back (not sure when) this worked fine, and tab would correctly focus on the next input, without browser forcing focus on the address bar.
o
I have a guess. Does the issue happen only when the focus is already in a TextField? If so, then I believe it's this issue - https://youtrack.jetbrains.com/issue/CMP-9041
r
Yes, the text field is focused, then the user presses tab, and this tab is intercepted by the browser's address bar. The next UI element still gains focus visually, but the "real" focus is in the address bar.
but it also happens when I press tab while focused on any other element, so it does not simply go up, it always goes to the address bar
o
> when I press tab while focused on any other element, So like when focused on a button too?
r
seems like when I press tab while focused on a button, the whole canvas gains a blue focus outline
o
got it. it's a bit different issue - https://youtrack.jetbrains.com/issue/CMP-9040 (from another thread)
👍 1