Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG FIX: adding count check for navigation stack before getting last item, adding check for mainpage as current page as additional failover. #2379

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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 @@ -157,12 +157,19 @@ static bool TryGetCurrentPage([NotNullWhen(true)] out Page? currentPage)
}

// If not using Shell or a Modal Page, return the visible page in the (non-modal) NavigationStack
if (window.Navigation.NavigationStack[^1] is Page page)
if (window.Navigation.NavigationStack.Count > 0 && window.Navigation.NavigationStack[^1] is Page page)
{
currentPage = page;
return true;
}

if (Application.Current != null && Application.Current.MainPage != null && Application.Current.MainPage is Page mainPage)
Copy link
Collaborator

@brminnick brminnick Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI - Once #2215 is merged, we will need to modify this to use Application.Current.Window instead of Application.Current.MainPage because MainPage is deprecated in .NET 9: https://learn.microsoft.com/en-us/dotnet/maui/whats-new/dotnet-9?view=net-maui-9.0#mainpage

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also FYI - you can ignore the current build errors in our CI pipeline. Those too will be resolved when we merge #2215

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Is there anything I need to do for now?

Copy link
Collaborator

@brminnick brminnick Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are in a code freeze until we merge #2215.

You'll need to fix this before we can merge this PR because it will cause a compiler error in .NET 9. This PR will not be merged before #2215.

{
currentPage = mainPage;
return true;
}


return false;

static bool TryGetModalPage(Window window, [NotNullWhen(true)] out Page? page)
Expand Down
Loading