Input cancellation - Jetpack Compose

In Jetpack Compose, you should avoid execution actions before user finishes the click gesture (such as click or long press). Standard Composables or Composables with the clickable modifier have built-in support for cancellation.

If you need more fine-grained control over gestures, you need to wait for the action to be released. This can be done, by using for example, tryAwaitRelease for click actions.

Box(
    modifier = Modifier
        .pointerInput(Unit) {
            detectTapGestures(
                onPress = {
                    if (tryAwaitRelease()) {
                        // your action ...   
                    }
                }
            )
        }
)