https://kotlinlang.org logo
#compose
Title
# compose
a

Alex C

11/25/2021, 4:33 AM
Anyone know how I can debug the onClick event? Somehow I couldn't get the button click event triggered
Copy code
@Composable
fun TestClick() {
    Box(modifier = Modifier
        .background(Color.Red)
        .padding(40.dp)
    ) {
        Column(
            modifier = Modifier
                .background(Color.Green)
                .clickable { Log.d("Test", "Column onClick") }
                .padding(40.dp)
        ) {
            Button(onClick = { Log.d("Test", "Button onClick") }) {
                Text(text = "Click", fontSize = 24.sp)
            }
        }
    }
}
k

Kirill Grouchnikov

11/25/2021, 5:12 AM
What if you remove the clickable modifier from its parent column?
a

Alex C

11/25/2021, 5:19 AM
Same result. I was trying different scenarios hence the Column clickable. What I'm having is if I click the area of a parent layout which has no clickable modifier(the Box) first, then click the child clickable components, the onclick event of the child will not be triggered. Which is very weird I copied the same compsable code in a brand new project, it works. But the same code in my existing project doesn't work.
After many test I finally find that if I add animation-graphic dependency in build.gradle, this bug will appear. Removing this dependency fixes this issue. @Doris Liu could you help?
d

Doris Liu

11/29/2021, 6:50 PM
Could you file a bug including the minimal repro code? We'll investigate.
a

Alex C

11/29/2021, 7:42 PM
Yes sure. Could you send me a link?
d

Doris Liu

11/29/2021, 7:51 PM
You can find this link (https://issuetracker.google.com/issues?q=componentid:612128) in the project page of this slack channel. 🙂
a

Alex C

11/29/2021, 7:52 PM
Cool thank you!
4 Views