Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,17 @@ Task<Page> PopModalPlatformAsync(bool animated)
}
else
{
dialogFragment.Dismiss();
// When batch-dismissing modals (e.g., PopToRoot), use DismissNow() to
// remove the fragment synchronously. This prevents intermediate modals
// from briefly flashing on screen between sequential pops.
bool isBatchPopping = _window.Page is Shell shell
&& shell.CurrentItem?.CurrentItem?.IsPoppingModalStack == true;

if (isBatchPopping)
dialogFragment.DismissNow();
else
dialogFragment.Dismiss();

source.TrySetResult(modal);
}

Expand Down
40 changes: 40 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue26846.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace Maui.Controls.Sample.Issues;
[Issue(IssueTracker.Github, 26846, "Shell PopToRootAsync doesn't happen instantly - previous pages flash quickly", PlatformAffected.Android)]
public class Issue26846 : TestShell
{
protected override void Init()
{
AddContentPage(new ContentPage()
{
Content = new VerticalStackLayout
{
Children =
{
new Label { Text = "This is a modal page1" },
new Button { Text = "Open modal page2", AutomationId="OpenModalPage2", Command = new Command(async () => await Navigation.PushModalAsync(new ContentPage()
{
Content = new VerticalStackLayout
{
Children = {
new Label { Text = "This is a modal page2" },
new Button { Text = "Open modal page3", AutomationId="OpenModalPage3", Command = new Command(async () => await Navigation.PushModalAsync(new ContentPage()
{
Content = new VerticalStackLayout
{
Children = {
new Label { Text = "This is a modal page3" },
new Button { Text = "Close", AutomationId="CloseModalPage3", Command = new Command(async () => await Navigation.PopModalAsync(false)) },
new Button { Text = "PopRoot", AutomationId="PopRootPage3", Command = new Command(async () => await Navigation.PopToRootAsync(false)) },
new Button { Text = "PopRoot Animated", AutomationId="PopRootPage4", Command = new Command(async () => await Navigation.PopToRootAsync()) }
}
}
})) },
new Button { Text = "Close", AutomationId="CloseModalPage2", Command = new Command(async () => await Navigation.PopModalAsync(false)) }
}
}
})) },
}
}
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;
public class Issue26846 : _IssuesUITest
{
public Issue26846(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "Shell PopToRootAsync doesn't happen instantly - previous pages flash quickly";

[Test]
[Category(UITestCategories.Navigation)]
public void ModalPoppingShouldWorkOneByOne()
{
App.WaitForElement("OpenModalPage2");
Comment on lines +14 to +18
App.Click("OpenModalPage2");
App.WaitForElement("OpenModalPage3");
App.Click("OpenModalPage3");
App.WaitForElement("CloseModalPage3");
App.Click("CloseModalPage3");
App.WaitForElement("CloseModalPage2");
App.Click("CloseModalPage2");

App.WaitForElement("OpenModalPage2");
}

[Test]
[Category(UITestCategories.Navigation)]
public void PopToRootShouldDismissAllModalsInstantly()
{
App.WaitForElement("OpenModalPage2");
App.Click("OpenModalPage2");
App.WaitForElement("OpenModalPage3");
App.Click("OpenModalPage3");
App.WaitForElement("PopRootPage3");
App.Click("PopRootPage3");

App.WaitForElement("OpenModalPage2");
}
}
Loading