Skip to content

Commit

Permalink
fix: Use LogicalParentOverride for PopupPanel everywhere
Browse files Browse the repository at this point in the history
Previously it was used only on WASM and Skia, but that caused odd issues, because routed events got propagated from Popups to the logical parents
  • Loading branch information
MartinZikmund committed Jul 11, 2023
1 parent a6e2d77 commit 4964759
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 9 deletions.
5 changes: 0 additions & 5 deletions src/Uno.UI/UI/Xaml/DependencyObjectExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,12 @@ internal static bool TrySetParent(this object dependencyObject, object parent)

internal static void SetLogicalParent(this FrameworkElement element, DependencyObject logicalParent)
{
#if UNO_HAS_MANAGED_POINTERS || __WASM__ // WASM has managed-esque pointers

// UWP distinguishes between the 'logical parent' (or inheritance parent) and the 'visual parent' of an element. Uno already
// recognises this distinction on some targets, but for targets using CoerceHitTestVisibility() for hit testing, the pointer
// implementation depends upon the logical parent (ie DepObjStore.Parent) being identical to the visual parent, because it
// piggybacks on the DP inheritance mechanism. Therefore we use LogicalParentOverride as a workaround to modify the publicly-visible
// FrameworkElement.Parent without affecting DP propagation.
element.LogicalParentOverride = logicalParent;
#else
SetParent(element, logicalParent);
#endif
}

/// <summary>
Expand Down
4 changes: 0 additions & 4 deletions src/Uno.UI/UI/Xaml/FrameworkElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ Windows.UI.Xaml.ResourceDictionary Resources
new
#endif
DependencyObject Parent =>
#if UNO_HAS_MANAGED_POINTERS || __WASM__
LogicalParentOverride ??
#endif
((IDependencyObjectStoreProvider)this).Store.Parent as DependencyObject;

public global::System.Uri BaseUri
Expand All @@ -193,12 +191,10 @@ Windows.UI.Xaml.ResourceDictionary Resources
}
}

#if UNO_HAS_MANAGED_POINTERS || __WASM__
/// <summary>
/// Allows to override the publicly-visible <see cref="Parent"/> without modifying DP propagation.
/// </summary>
internal DependencyObject LogicalParentOverride { get; set; }
#endif

/// <summary>
/// Provides the managed visual parent of the element. This property can be overriden for specific
Expand Down

0 comments on commit 4964759

Please sign in to comment.