Consider following `Composable`. ```Box( modifier = Modifier .size(100.dp) .back...
t
Consider following
Composable
.
Copy code
Box(
    modifier = Modifier
        .size(100.dp)
        .background(Color.Blue)
        .clickable {
            // parent click listener
            Timber.d("parent click")
        }
) {
    Box(
        modifier = Modifier
            .size(50.dp)
            .background(Color.Red)
    ) {
        // children
    }

    // ...
}
When clicking on the red
Box
the parent
Composable
consumes the click event even though the red box is in front of it. This looks like a weird default behavior to be. Different from the
View
system.... However when the red
Box
has a click listener of its own the behavior is correct and the red
Box
click listener is triggered. Is there a better way to let the red
Box
consume the event without putting an explicit
clickable
modifier on it?
s
I don't think so. The simplest solution is adding
Modifier.pointerInput(Unit) { detectTapGesturs {} }
to the red box
l
If you don't specify a pointer event listener on red box, it won't listen for it.