Skip to content

Commit

Permalink
fix: Avoid propagating routed events up from PopupPanel
Browse files Browse the repository at this point in the history
In case of UWP and WinUI, routed events are not propagated up from Popups, even if they are part of the visual tree and their Parent is set. Because we currently override the logical parent on Android and iOS by overwriting the actual parent, the only way to stop the propagation is to actually stop it at the PopupPanel level.

(cherry picked from commit 326a0ec)
  • Loading branch information
MartinZikmund authored and mergify[bot] committed Jul 20, 2023
1 parent db7ba1f commit 3f7c219
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/Uno.UI/UI/Xaml/UIElement.RoutedEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
using Uno.UI.Xaml.Input;
using Windows.Foundation;
using Windows.UI.Xaml.Input;
using Uno.UI.Xaml.Core;
using Windows.UI.Xaml.Controls.Primitives;

#if __IOS__
using UIKit;
Expand Down Expand Up @@ -719,15 +721,20 @@ internal bool RaiseEvent(RoutedEvent routedEvent, RoutedEventArgs args, Bubbling
args.CanBubbleNatively = false;
}

var parent = this.GetParent() as UIElement;
UIElement parent = null;
if (this is not PopupPanel)
{
parent = this.GetParent() as UIElement;

#if __IOS__ || __ANDROID__
// This is for safety (legacy support) and should be removed.
// A common issue is the managed parent being cleared before unload event raised.
parent ??= this.FindFirstParent<UIElement>();
// This is for safety (legacy support) and should be removed.
// A common issue is the managed parent being cleared before unload event raised.
parent ??= this.FindFirstParent<UIElement>();
#endif
}

// [11] A parent is defined?
if (parent == null)
if (parent is null)
{
return isHandled; // [12] processing finished
}
Expand Down

0 comments on commit 3f7c219

Please sign in to comment.