Skip to content

Commit

Permalink
fix(uielement): [iOS] Fix TransformToVisual output inside ScrollViewer
Browse files Browse the repository at this point in the history
Fix scroll offset being double-applied to TransformToVisual offset. This fixes Flyouts not being positioned properly when attached to an anchor in scrolled content.
  • Loading branch information
davidjohnoliver committed Feb 5, 2021
1 parent dafef4b commit ade31cb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class UIElementTests : SampleControlUITestBase
// TODO: convert this to RuntimeTests https://github.com/unoplatform/uno/issues/2114#issuecomment-555209397
[Test]
[AutoRetry]
[ActivePlatforms(Platform.Browser)]
public void When_TransformToVisual_Transform()
{
Run("UITests.Shared.Windows_UI_Xaml.UIElementTests.TransformToVisual_Transform", skipInitialScreenshot: false);
Expand All @@ -27,7 +26,6 @@ public void When_TransformToVisual_Transform()
// TODO: convert this to RuntimeTests https://github.com/unoplatform/uno/issues/2114#issuecomment-555209397
[Test]
[AutoRetry]
[ActivePlatforms(Platform.Browser)]
public void When_TransformToVisual_ScrollViewer()
{
Run("UITests.Shared.Windows_UI_Xaml.UIElementTests.TransformToVisual_ScrollViewer", skipInitialScreenshot: false);
Expand Down
4 changes: 3 additions & 1 deletion src/Uno.UI/UI/Xaml/UIElement.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,14 @@ private bool TryGetParentUIElementForTransformToVisual(out UIElement parentEleme
// We found a UIElement in the parent hierarchy, we compute the X/Y offset between the
// first parent 'view' and this 'elt', and return it.

if (view is UICollectionView)
if (view is UICollectionView || view is NativeScrollContentPresenter)
{
// The UICollectionView (ListView) will include the scroll offset when converting point to coordinates
// space of the parent, but the same scroll offset will be applied by the parent ScrollViewer.
// So as it's not expected to have any transform/margins/etc., we compute offset directly from its parent.

// The same logic applies to NativeScrollContentPresenter, since the ScrollViewer offsets will be explicitly taken into account.

view = view.Superview;
}

Expand Down

0 comments on commit ade31cb

Please sign in to comment.