dotnet / dotnet/maui

iOS: Blank Root Page When Navigation Triggered within Shell Navigation Event

Open
#37,360 0 comments 1 reaction 0 assignees View on GitHub
t/bug
Dominant language
C#
Stars
23.3k
Forks
2k
Avg merge
1d 15h
Merged PRs (30d)
290

Description

### Description

In my app, I have a need to show a modal, and then when that modal is dismissed, navigate to a new page. For the LONGEST time, the app behaviour was basically that occasionally the root page would go blank for no particular reason, and this bug couldn't be pinned down. Finally I let Claude take a crack at it and after a few days, he/she/it found the issue.

I was hesitant to report this as possibly it seems like a bad idea to trigger a navigation inside of a navigation event, but I decided to report it as there doesn't appear to be another way to go about triggering a navigation on a page close in shell (that I am aware of), and some one else may have this problem, and be just as frusterated with trying to find it (in my case, I switched to NavigationPage and FlyoutPage, but had to switch back due to other bugs on Android).

Claude also reported that there IS a defect that this behaviour uncovers, and it can be read about in the Reproduction Project ReadMe file I've linked.

### Steps to Reproduce

1. Create a Shell with a Root Page, a Modal Page, and a Detail Page.
2. Add a Handler to the Shell's NavigatedTo Event to push the regular page when Modal page is effectively dismissed.
3. Navigate to the Modal Page.
4. Dismiss the Modal Page, the app should automatically navigate to the Detail Page.
5. Dismiss the Detail Page.

Expected Result: Root Page is displaying

Actual Result: Root Page is blank, or will be blank in the future as it is marked to be destroyed.

### Link to public reproduction project repository

https://github.com/asi-evin/ShellBlankRootPageRepro

### Version with bug

10.0.90

### Is this a regression from previous behavior?

No, this is something new

### Last version that worked well

_No response_

### Affected platforms

iOS

### Affected platform versions

_No response_

### Did you find any workaround?

It looks like you can add a delay to ensure navigation is finished (not ideal if you want to do your best to prevent UI interaction), or run the new Navigation in a Task that is created with the "TaskCreationOptions.RunContinuationsAsynchronously" flag. It is also possible to prevent this by changing the NavigationType to "Push" on the NavigatingFrom Event in your root page (which should NEVER be anything but). And finally you could avoid the Navihgation events all together by using Maui Commnity Toolkit popups IF it is able to suite your needs.

### Relevant log output

```shell

```

Contributor guide

Open the contributing guide

Research direction

Start with the linked ShellBlankRootPageRepro project and reproduce the issue on iOS with version 10.0.90, focusing on Shell NavigatedTo and the root page's NavigatingFrom behavior. Trace the modal-to-detail navigation sequence and verify that dismissing the detail page leaves the root page displayed rather than blank or marked for destruction.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, ios
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.