I have a `FlowRow` with multiple child `Chip`s. I ...
# compose
m
I have a
FlowRow
with multiple child `Chip`s. I can’t find a way to prevent the `Chip`s from being clickable. I just want the whole
FlowRow
to be clickable (
Modifier.onClick
) as a single target. Note, I’ve tried setting
enabled = false
on the `Chip`s but this still steals the click event.
s
Not sure how to do that with the click events, but if you want those chips to not be interactive at all, sounds like you may just want their color+shape. So if you don’t find a way to do this, maybe doing a simple Box with the chip shape and the chip colors may be your best bet. Just as a temp solution maybe till someone else knows how to fix the other problem
m
Yeah, thanks that should work. I currently went a different hack route, and just stick the
FlowRow
in a
Box
so that I can put another
Box
(transparent) on top of it (second child of parent
Box
) So the second
Box
has the clickable modifier, so that the
FlowRow
never receives click events, and that seems to work okay.
s
Modern problems require modern solutions 😅
m
Haha! Interestingly sticking the onClick modifier on the parent box doesn’t help. Any ideas why?
s
I really haven’t dealt with any issue like this before tbh, so I really don’t have specific knowledge on this. But doesn’t it make sense if a child has a click handler that it takes precedence over the parent? Regarding it consuming the click events when it’s disabled, that’s another story and I am not sure why that is the case, if it’s on purpose and if it’s trying to solve some issues that we may not be thinking about rn
m
Yeah, I guess it makes sense that children handle click events first. I just assume there would be a way for the parent to override events so they don’t hit their children.
j
It is possible for parents to hijack click events from their children, by using a pointerInput modifier on the parent and listen to pointer events in the Initial pass. See the new guide on gestures: https://developer.android.com/jetpack/compose/touch-input/pointer-input/understand-gestures In this case however, could you check the implementation of the Chip and see if it's easy to copy and remove the clickable behavior?