Sam
06/12/2026, 3:52 AMcollectIsPressedAsState of InteractionSource claims pressed state even when otherwise when the item is within a scrollable lazy row/column.Sam
06/12/2026, 3:52 AM@Composable
fun InteractionSource.collectIsPressedAsState(): State<Boolean> {
val isPressed = remember { mutableStateOf(false) }
LaunchedEffect(this) {
val pressInteractions = mutableListOf<PressInteraction.Press>()
interactions.collect { interaction ->
when (interaction) {
is PressInteraction.Press -> pressInteractions.add(interaction)
is PressInteraction.Release -> pressInteractions.remove(interaction.press)
is PressInteraction.Cancel -> pressInteractions.remove(interaction.press)
}
isPressed.value = pressInteractions.isNotEmpty()
}
}
return isPressed
}Sam
06/12/2026, 3:53 AMpressInteractions retains a Press interaction and isn't removed.Sam
06/12/2026, 3:54 AMZach Klippenstein (he/him) [MOD]
06/12/2026, 12:56 PMMutableInteractionSource can be passed to multiple components, which can each emit their own Press interactions.Sam
06/12/2026, 4:03 PMinteractions could be canceled before processing the release/cancel event causing the count discrepancy. Is this a known issue?Zach Klippenstein (he/him) [MOD]
06/12/2026, 4:42 PMSam
06/13/2026, 2:32 AMDefaultDebugIndicationSam
06/13/2026, 2:36 AMDefaultDebugIndicationInstance, isPressed should have been true. Any tips to debug this?
override fun ContentDrawScope.draw() {
drawContent()
if (isPressed) {
drawRect(color = Color.Black.copy(alpha = 0.3f), size = size)
} else if (isHovered || isFocused) {
drawRect(color = Color.Black.copy(alpha = 0.1f), size = size)
}
}Sam
06/15/2026, 12:35 AMhandlePressInteractionRelease and handlePressInteractionStart of clickable node when the clickable element is within a scrollable container.Sam
06/15/2026, 12:36 AMSam
06/15/2026, 12:39 AM