-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[Regression] ListBoxItems and children no longer reliably generate Tapped events from Touch input. #13474
Comments
Looking at it some more after the weekend, the problem seems to be that while PointerPressed events have their source set to the appropriate Textblock/Border/etc control, corresponding PointerReleased events have their source set to the ListBox. As they don't match, no Tapped events are generated. DoubleTapped is generated on PointerPressed, so there's no issue. This only applies to Touch pointers though, Mouse pointers generate PointerReleased events with the appropriate source set. I'm going to try and figure out why Touch pointers are creating PointerReleased events with unexpected sources. |
The PointerReleasedEventArgs are initially getting created with the correct source, but ListBoxItem is doing the following in its own OnPointerReleased():
Calling owner.RaiseEvent(e) causes the source of the event to be overwritten with owner, in this case the ListBox, which results in Tapped event generation breaking because the PointerPressed and PointerReleased events now have different sources. That puts the cause of the regression as Commit #12883. |
So I'm looking into this more and trying to prep a PR, because this is a pretty big problem I feel, and I'm a bit confused about some of the Unit Test helpers. Specifically the TouchTestHelper. The TouchTestHelper raises the various pointer events with no mouse button, which makes sense given we're taking about touch, but in the wild the real events are LeftMouseButton related. TouchDevice seems to, by default, make Pointer event args with LeftMouseButton pressed. Tapped events are also only generated if there is a Left or Right mouse button pressed. Does this mean I shouldn't be using the TouchTestHelper, because it doesn't reflect real life use cases, or that TouchTestHelper should be changed to assume a Left mouse button touch unless otherwise specified? |
@emmauss do you have any hints? |
My proposed fix is essentially rolling back the change made to ListBoxItem as part of the AutoCompleteBox focus fixes. Looking into every bit I can think of I'm still not sure why the event needs to be raised again, rather than simply bubbling up to the ListBox. I'd appreciate any insight on that suggestion as well. |
* Failing unit test for #13474 * Fix for #13474 by reverting changes to ListBoxItem from #12883 * Version 2 of fix, only marks event handled for Mouse input. * Version 3. Re-raise the event, but backup the source before doing so and restore it after. Closest in functionality to original, but preserves "correct" event source in order to allow Tapped events. --------- Co-authored-by: Jumar Macato <[email protected]>
Describe the bug
ListBoxItems or their children (with the exception of Buttons at least) no longer generate Tapped events or trigger Tapped event handlers when the input comes from a touch device. Mouse clicks still generate Tapped events as expected. Both generate DoubleTapped events.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Both mouse input and touch input generate Tapped events.
Environment
Additional context
Looking through the list of commits from Avalonia 11.0.4 to 11.0.5 the only one that seems potentially relevant is #12666,
although I don't know nearly enough about the whole GestureRecognizer system to comment with any certainty.
Using a Surface Go 4 to check has been a boon, as the use of DevTools has allowed me to confirm that nowhere within the bounds of a ListBoxItem is generating Tapped events from touch input, with the exception of the bounds of the Button.
The text was updated successfully, but these errors were encountered: