Skip to content

Commit ade31cb

Browse files
fix(uielement): [iOS] Fix TransformToVisual output inside ScrollViewer
Fix scroll offset being double-applied to TransformToVisual offset. This fixes Flyouts not being positioned properly when attached to an anchor in scrolled content.
1 parent dafef4b commit ade31cb

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml/UIElementTests/UIElementTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public class UIElementTests : SampleControlUITestBase
1616
// TODO: convert this to RuntimeTests https://github.com/unoplatform/uno/issues/2114#issuecomment-555209397
1717
[Test]
1818
[AutoRetry]
19-
[ActivePlatforms(Platform.Browser)]
2019
public void When_TransformToVisual_Transform()
2120
{
2221
Run("UITests.Shared.Windows_UI_Xaml.UIElementTests.TransformToVisual_Transform", skipInitialScreenshot: false);
@@ -27,7 +26,6 @@ public void When_TransformToVisual_Transform()
2726
// TODO: convert this to RuntimeTests https://github.com/unoplatform/uno/issues/2114#issuecomment-555209397
2827
[Test]
2928
[AutoRetry]
30-
[ActivePlatforms(Platform.Browser)]
3129
public void When_TransformToVisual_ScrollViewer()
3230
{
3331
Run("UITests.Shared.Windows_UI_Xaml.UIElementTests.TransformToVisual_ScrollViewer", skipInitialScreenshot: false);

src/Uno.UI/UI/Xaml/UIElement.iOS.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,14 @@ private bool TryGetParentUIElementForTransformToVisual(out UIElement parentEleme
166166
// We found a UIElement in the parent hierarchy, we compute the X/Y offset between the
167167
// first parent 'view' and this 'elt', and return it.
168168

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

175+
// The same logic applies to NativeScrollContentPresenter, since the ScrollViewer offsets will be explicitly taken into account.
176+
175177
view = view.Superview;
176178
}
177179

0 commit comments

Comments
 (0)