compose-multiplatform icon indicating copy to clipboard operation
compose-multiplatform copied to clipboard

Multi touch tap events failing on desktop

Open EricWarburton opened this issue 1 year ago • 1 comments

Describe the bug When tapping multiple times on the same button/card quickly the final touch event doesn't finish.

Affected platforms

  • Desktop (Windows)

Versions

  • Kotlin version*: 1.9.23
  • Compose Multiplatform version*: 1.6.1
  • OS version(s)*: Windows 11
  • OS architecture: x64
  • Device (model or simulator for iOS issues): reproduced on elo touch monitor and acer touch monitor
  • JDK (for desktop issues): reproduced on both 21 and 11

To Reproduce Steps and/or the code snippet to reproduce the behavior: (Note: Click works as expected) Double tap a button, if you have a counter tied to the button the counter will move up by one. You should notice the button will remain highlighted. From there there are a couple scenarios.

  • 3rd tap on the same button => counter will jump to 3
  • 3rd tap anywhere else => counter will remain on 1
  • Move mouse at all => counter moves to 2

` import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.material3.Button import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import org.jetbrains.compose.ui.tooling.preview.Preview

@Composable @Preview fun App() { MaterialTheme { var counter1 by remember { mutableStateOf(0) } var counter2 by remember { mutableStateOf(0) } var counter3 by remember { mutableStateOf(0) }

    Column(
        verticalArrangement = Arrangement.Center,
        horizontalAlignment = Alignment.CenterHorizontally,
        modifier = Modifier.fillMaxSize()
    ) {
        Row(
            horizontalArrangement = Arrangement.Center
        ) {
            ButtonWithCounter("Button 1", mutableStateOf(counter1)) { counter1++ }
            ButtonWithCounter("Button 2", mutableStateOf(counter2)) { counter2++ }
            ButtonWithCounter("Button 3", mutableStateOf(counter3)) { counter3++ }
        }
        Spacer(Modifier.height(16.dp))
        Row(
            horizontalArrangement = Arrangement.Center
        ) {
            Button(onClick = {
                counter1 = 0
                counter2 = 0
                counter3 = 0
            }) { Text(text = "Clear Values") }
        }
    }
}

}

@Composable fun ButtonWithCounter(buttonText: String, counter: MutableState<Int>, onClick: () -> Unit) { Column( horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier.padding(8.dp) ) { Button(onClick = onClick) { Text(buttonText) } Text(text = "Counter: ${counter.value}") } } `

Expected behavior I expect the button to fire the event when tapped, even if tapped over and over.

Screenshots Button Multiple Tap Bug

EricWarburton avatar Apr 23 '24 20:04 EricWarburton

@Schahen This looks like wrong usage of states. Can you check, please?

m-sasha avatar Apr 24 '24 09:04 m-sasha

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

okushnikov avatar Jul 14 '24 15:07 okushnikov