diff --git a/src/Controls/src/Core/Compatibility/Handlers/FlyoutPage/iOS/PhoneFlyoutPageRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/FlyoutPage/iOS/PhoneFlyoutPageRenderer.cs index 67816eb67274..db073e4cebcc 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/FlyoutPage/iOS/PhoneFlyoutPageRenderer.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/FlyoutPage/iOS/PhoneFlyoutPageRenderer.cs @@ -390,7 +390,7 @@ void LayoutChildren(bool animated) if (IsRTL && !FlyoutOverlapsDetailsInPopoverMode) { - flyoutFrame.X = (int)(flyoutFrame.Width * .25); + flyoutFrame.X = (int)(frame.Width - flyoutFrame.Width); } var detailsFrame = frame; diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue2818.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue2818.cs index 33a8c2f828c9..f75526c505f8 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue2818.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue2818.cs @@ -1,6 +1,5 @@ -#if TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_IOS +#if TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_CATALYST // Orientation not supported in Catalyst and Windows -// On iOS FlyoutPage RTL is not working as expected, Issue: https://github.com/dotnet/maui/issues/26726 using NUnit.Framework; using UITest.Appium; using UITest.Core; @@ -35,8 +34,8 @@ public void RootViewMovesAndContentIsVisible() Assert.That(positionStart, Is.Not.EqualTo(secondPosition)); } - [Test] - public void RootViewSizeDoesntChangeAfterBackground() + [Test] + public async Task RootViewSizeDoesntChangeAfterBackground() { var idiom = App.WaitForElement("Idiom"); App.SetOrientationLandscape(); @@ -52,6 +51,17 @@ public void RootViewSizeDoesntChangeAfterBackground() App.WaitForNoElement("RootLayout"); App.ForegroundApp(); var newWindowSize = App.WaitForElement("RootLayout"); + + // Poll until the width stabilizes. After foregrounding, some platforms (esp. Android/iOS) + // may momentarily report an intermediate layout size while the window / flyout re-applies + // RTL + orientation constraints. This loop prevents test flakiness by waiting for the + // final (restored) size instead of asserting too early + int retries = 50; + while (newWindowSize.GetRect().Width != windowSize.GetRect().Width && retries-- > 0) + { + await Task.Delay(100); + } + Assert.That(newWindowSize.GetRect().Width, Is.EqualTo(windowSize.GetRect().Width)); Assert.That(newWindowSize.GetRect().Height, Is.EqualTo(windowSize.GetRect().Height)); }