Skip to content

Commit

Permalink
fix: fix hit testing on skia when Canvas.ZIndex is used with non-canv…
Browse files Browse the repository at this point in the history
…as panels
  • Loading branch information
ramezgerges committed Feb 26, 2024
1 parent 42f614e commit a47d65f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Uno.UI/UI/Xaml/Media/VisualTreeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -543,14 +543,15 @@ private static (UIElement? element, Branch? stale) SearchDownForTopMostElementAt

var isChildStale = isStale;

// We only take ZIndex into account on skia, which supports Canvas.Zindex for non-canvas panels.
// Once Canvas.ZIndex renders correctly elsewhere, remove the conditional OrderBy
// https://github.com/unoplatform/uno/issues/325
using var child = children
#if __IOS__ || __MACOS__ || __ANDROID__ || IS_UNIT_TESTS
.Reverse().GetEnumerator();
#else
// On Skia and Wasm, we can get concrete data structure (MaterializableList in this case) instead of IEnumerable<T>.
// It has an efficient "ReverseEnumerator". This will also avoid the boxing allocations of the enumerator when it's a struct.
.GetReverseEnumerator();
#if __SKIA__
.OrderBy(e => e.Visual.ZIndex) // Equivalent to GetValue(Canvas.ZIndexProperty) on skia
#endif
.Reverse()
.GetEnumerator();

while (child.MoveNext())
{
Expand Down

0 comments on commit a47d65f

Please sign in to comment.