- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.9k
 
Open
Labels
area-navigationNavigationPageNavigationPagei/regressionThis issue described a confirmed regression on a currently supported versionThis issue described a confirmed regression on a currently supported versionpartner/syncfusionIssues / PR's with Syncfusion collaborationIssues / PR's with Syncfusion collaborationperf/memory-leak 💦Memory usage grows / objects live forever (sub: perf)Memory usage grows / objects live forever (sub: perf)platform/androidplatform/iosplatform/macosmacOS / Mac CatalystmacOS / Mac Catalystplatform/windowsregressed-in-9.0.40s/triagedIssue has been reviewedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering TriageVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingSomething isn't working
Milestone
Description
Description
When removing pages from a NavigationPage's navigation stack, using NavigationPage.Navigation.RemovePage() fails to properly disconnect handlers from the removed pages, while using ContentPage.Navigation.RemovePage() correctly disconnects handlers as expected.
Expected Behavior
When a page is removed from the navigation stack using RemovePage(), its handler should be disconnected regardless of whether you access the Navigation property through the NavigationPage or ContentPage.
Actual Behavior
- Button_OnClicked2 (correct behavior): Uses 
ContentPage.Navigation.RemovePage()→ handlers are properly disconnected from removed pages - Button_OnClicked (bug): Uses 
NavigationPage.Navigation.RemovePage()→ handlers remain connected to removed pages, preventing proper cleanup 
Code Example
// This FAILS to disconnect handlers (BUG)
private void Button_OnClicked(object? sender, EventArgs e)
{
    var navigationPage = Shell.Current.Navigation.ModalStack
        .FirstOrDefault(p => p is NavigationPage) as NavigationPage;
    var stack = navigationPage.Navigation.NavigationStack;
    var pages = stack.Take(stack.Count - 1).ToList();
    foreach (var page in pages)
    {
        navigationPage.Navigation.RemovePage(page); // Handlers stay connected
    }
    Navigation.PopModalAsync();
}
// This correctly disconnects handlers (Expected behavior)
private void Button_OnClicked2(object? sender, EventArgs e)
{
    var pages = Navigation.NavigationStack.Take(Navigation.NavigationStack.Count - 1).ToList();
    foreach (var page in pages)
    {
        Navigation.RemovePage(page); // Handlers are properly disconnected
    }
    Navigation.PopModalAsync();
}Steps to Reproduce
- Clone https://github.com/Vetle444/MauiTestApp/tree/popModalHandler
 - Make sure to use branch 
popModalHandler - Run app
 - Click button 
Test Page Modal - Click button 
Navigate to test page 2 - Click button 
Pop modal using NavigationPage - Observe that no dialog appears describing that the root page was disconnected
 - Now try popping modal using the other button
 - Observe that the dialog appears
 
Link to public reproduction project repository
https://github.com/Vetle444/MauiTestApp/tree/popModalHandler
Version with bug
9.0.110 SR12
Is this a regression from previous behavior?
Yes, this used to work in Xamarin.Forms
Last version that worked well
No response
Affected platforms
iOS, Android, macOS, Windows
Affected platform versions
No response
Did you find any workaround?
Make sure to call .DisconnectHandlers after removing the page
Relevant log output
Metadata
Metadata
Assignees
Labels
area-navigationNavigationPageNavigationPagei/regressionThis issue described a confirmed regression on a currently supported versionThis issue described a confirmed regression on a currently supported versionpartner/syncfusionIssues / PR's with Syncfusion collaborationIssues / PR's with Syncfusion collaborationperf/memory-leak 💦Memory usage grows / objects live forever (sub: perf)Memory usage grows / objects live forever (sub: perf)platform/androidplatform/iosplatform/macosmacOS / Mac CatalystmacOS / Mac Catalystplatform/windowsregressed-in-9.0.40s/triagedIssue has been reviewedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering TriageVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingSomething isn't working
