Hi everyone :wave: I updated my compose version fr...
# compose-desktop
n
Hi everyone 👋 I updated my compose version from 1.8.2 to 1.9.0-beta03 and I encountered the following bug on desktop. When I click with mouse on a clickable element, the element keeps the focus in the same way that if I select this element with the keyboard (with the default LocalIndication). I tried to debug it, and I found that the
FocusInteraction.Unfocus
is never called. I found this old issue that seems close to mine, but I'm not sure. Any idea if it's a bug or an accessibility feature ? Works fine on Android & iOS (no
HoverInteraction
/
FocusInteraction
calls, which seems logic) (code & video in 🧵) Thanks 🙂
Minimal code reproduction :
Copy code
Box(
    modifier = Modifier.fillMaxSize(),
    contentAlignment = Alignment.Center,
) {
    Column(
        horizontalAlignment = Alignment.CenterHorizontally,
        verticalArrangement = Arrangement.spacedBy(24.dp)
    ) {
        Text(
            modifier = Modifier.clickable {},
            text = "Click me",
        )
        Box(
            modifier = Modifier
                .clickable {}
                .background(Color.Cyan)
                .size(100.dp)
        )
    }
}
The first time, I hover both items => indication is removed The second time, I click on each item => indication stays
a
I’m not sure I understand the problem. Focus and hover indications are separate things.
n
The main issue is that Text (or Box) keeps the focus after I clicked the element (with the mouse). I expect the focus to stay only if I navigate with the keyboard.
a
Modifier.clickable makes the element focusable, and it requests focus on click.
It’s a bit surprising, I agree, but it’s as designed
If you only want to receive click events, use onClick or pointer events.
n
Makes sense. My last concern is that it was not working like that on Compose 1.8.2. Didn't find anything about this on the 1.9 changelog, that's why I think it was a bug.
a
I’m not sure, maybe it was a bug that it was missing
Hmm, maybe I was wrong. Whether the indication is showing is determined by the input mode. When you only use the mouse, the input mode should be
InputMode.Touch
, I guess, and the focus indication should not be shown.
I’ll look into it
Ok, I see where it’s coming from. Until we fix it, you can get the old behavior by setting
ComposeFoundationFlags.isNonComposedClickableEnabled = false
somewhere at the start of your app.
n
Hey Alexander, I just tested with this flag and it's working as expected, thanks 👍 Do you want me to fill an issue to this bug on YouTrack ?
Thanks for reporting the problem though.