compose/ui/web: fix incorrect interpretation of ontouchend
events
#2490
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In ComposeWindow.w3c.kt, the touch handler does not correctly handle the
touchend
event. Indeed the logic selecting betweentargetTouches
andchangedTouches
is flawed. Fortouchend
both should be taken into account, alsochangedTouches
contains the un-pressed pointer andtargetTouches
contains the rest of the remaining pressed pointers.The fix consists in removing the logic that compares the size of both
targetTouches
andchangedTouches
to pick the largest one.Instead, it checks the pointer event type to determine whether only
targetTouches
or bothtargetTouches
andchangedTouches
are needed while correctly accounting which touches are pressed depending on the source.Fixes: https://youtrack.jetbrains.com/issue/CMP-9030/wasm-canvas-incorrect-handling-of-multi-touch-input
Testing
I have added a failing test in
GestureTest.kt
which is subsequently fixed by the implementation commit. The test consists in using three touches that are progressively pressed (1, 2, 3) and unpressed (3, 2, 1), logging and comparing the behavior of the pointerInput modifier with the expected events.Release Notes
Fixes - Web
ontouchend
events.