Skip to content

Commit

Permalink
fix(pointers): Fix UI tests for wasm
Browse files Browse the repository at this point in the history
As the `CanBubbleNatively` is no longer overriden by the `EventRegistration`, the `PointerEnter` and `PointerLeave` was invalidly bubbling.
Settings this flag back to `true` (even if it's not the reallity) fixes the issue.
This however does not fix the issue described here #3007
  • Loading branch information
dr1rrb committed Apr 16, 2020
1 parent 9c4cff6 commit f928c55
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Uno.UI/UI/Xaml/UIElement.Pointers.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,17 @@ private void AddPointerHandlerCore(RoutedEvent routedEvent)
#endregion

#region Native event dispatch
// Note for Enter and Leave:
// canBubble: true is actually not true.
// When we subscribe to pointer enter in a window, we don't receive pointer enter for each sub-views!
// But the web-browser will actually behave like WinUI for pointerenter and pointerleave, so here by setting it to true,
// we just ensure that the managed code won't try to bubble it by its own.
// However, if the event is Handled in managed, it will then bubble while it should not! https://github.com/unoplatform/uno/issues/3007
private static bool DispatchNativePointerEnter(UIElement target, string eventPayload)
=> TryParse(eventPayload, out var args) && target.OnNativePointerEnter(ToPointerArgs(target, args, isInContact: false, canBubble: false));
=> TryParse(eventPayload, out var args) && target.OnNativePointerEnter(ToPointerArgs(target, args, isInContact: false, canBubble: true));

private static bool DispatchNativePointerLeave(UIElement target, string eventPayload)
=> TryParse(eventPayload, out var args) && target.OnNativePointerExited(ToPointerArgs(target, args, isInContact: false, canBubble: false));
=> TryParse(eventPayload, out var args) && target.OnNativePointerExited(ToPointerArgs(target, args, isInContact: false, canBubble: true));

private static bool DispatchNativePointerDown(UIElement target, string eventPayload)
=> TryParse(eventPayload, out var args) && target.OnNativePointerDown(ToPointerArgs(target, args, isInContact: true));
Expand Down

0 comments on commit f928c55

Please sign in to comment.