Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix keyboard opening when scrolling begins within a TextField #1176

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.util.fastAll
import androidx.compose.ui.util.fastAny
import androidx.compose.ui.util.fastForEach
import kotlinx.coroutines.*
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.currentCoroutineContext
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch

/**
* Detects tap, double-tap, and long press gestures and calls [onTap], [onDoubleTap], and
Expand Down Expand Up @@ -224,14 +227,18 @@ internal suspend fun PointerInputScope.detectRepeatingTapGestures(
awaitEachGesture {
val touchesCounter = ClicksCounter(viewConfiguration, clicksSlop = 50.dp.toPx())
while (true) {
val down = awaitFirstDown()
touchesCounter.update(down)
val downChange = down
val downChange = awaitFirstDown()
touchesCounter.update(downChange)
when (touchesCounter.clicks) {
1 -> {
if (onTap != null) {
onTap(downChange.position)
downChange.consume()
awaitReleaseOrCancelled(
ASalavei marked this conversation as resolved.
Show resolved Hide resolved
filter = { PointerMatcher.Primary.matches(it) },
consumeUntilRelease = false
)?.changes?.last()?.let {
onTap(it.position)
ASalavei marked this conversation as resolved.
Show resolved Hide resolved
it.consume()
}
}
}

Expand Down
Loading