Is there an existing issue for this?
Did you read the "Reporting a bug" section on Contributing file?
Current Behavior
Dismissing a popup by clicking outside of it will throw a PopupNotFoundException when the popup has been opened from a NavigationPage on the modal stack:
Expected Behavior
Dismissing the popup should work just fine
Steps To Reproduce
Run this code, after the popup appears, just click outside the popup to dismiss it
public class MainPage : ContentPage
{
protected override void OnAppearing()
{
base.OnAppearing();
this.Navigation.PushModalAsync(
new NavigationPage(
new PopupLauncherContentPage()));
}
}
public class PopupLauncherContentPage : ContentPage
{
private bool _appeared = false;
protected override void OnAppearing()
{
base.OnAppearing();
if (this._appeared)
{
return;
}
var popup = new Popup()
{
Content = new Label { Text = "Hello Popup!" },
CanBeDismissedByTappingOutsideOfPopup = true
};
this.Navigation.ShowPopup(popup);
this._appeared = true;
}
}
Exception thrown
CommunityToolkit.Maui.Views.PopupNotFoundException: Unable to close popup: could not locate PopupPage. ShowPopup or ShowPopupAsync must be called before CloseAsync. If using a custom implementation of Popup, override the CloseAsync method
at CommunityToolkit.Maui.Views.PopupPage.CloseAsync(PopupResult result, CancellationToken token) in /_/src/CommunityToolkit.Maui/Views/Popup/PopupPage.shared.cs:line 83
at CommunityToolkit.Maui.Views.PopupPage.<>c__DisplayClass4_0.<<-ctor>b__0>d.MoveNext() in /_/src/CommunityToolkit.Maui/Views/Popup/PopupPage.shared.cs:line 46
--- End of stack trace from previous location ---
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__124_0(Object state)
at Android.App.SyncContext.<>c__DisplayClass2_0.<Post>b__0()
at Java.Lang.Thread.RunnableImplementor.Run()
at Java.Lang.IRunnableInvoker.n_Run(IntPtr jnienv, IntPtr native__this)
Link to public reproduction project repository
Sample provided in the ticket description
Environment
- .NET MAUI CommunityToolkit:14.0.1
- OS: MacOS
- .NET MAUI:10.0.50
Anything else?
May relate to #2839
Is there an existing issue for this?
Did you read the "Reporting a bug" section on Contributing file?
Current Behavior
Dismissing a popup by clicking outside of it will throw a
PopupNotFoundExceptionwhen the popup has been opened from aNavigationPageon the modal stack:Expected Behavior
Dismissing the popup should work just fine
Steps To Reproduce
Run this code, after the popup appears, just click outside the popup to dismiss it
Exception thrown
Link to public reproduction project repository
Sample provided in the ticket description
Environment
Anything else?
May relate to #2839