maui icon indicating copy to clipboard operation
maui copied to clipboard

NavigationPage does not close reliably

Open AlphaNERD- opened this issue 1 year ago • 4 comments

Description

I am facing an issue which causes a NavigationPage to "stick". Basically when i want to close the Page using Navigation.PopAsync, the same page is opened again. Another thing that can happen is that the previous page does pop up after a second tap on the back and going back from there or forward does not work properly anymore.

Something of note that may mess with the navigation is that i removed the AppShell. That is because in the original project the repro project is based on i couldn't figure out how to open a different page than the page declared in the AppShell.xaml depending on a few conditions.

Steps to Reproduce

  1. Clone my repro project.
  2. Tap the Button "Show an error".
  3. Use the Back button to go back to the previous page.
  4. Tap the Button "Do something" to go to the next page.

Going forward and back has worked so far.

  1. Tap the Button "Show an error".
  2. Use the back button to go back again.
  3. Tap the Button "Do something again" to go to the next page.

Going forward and back has worked again. The next page will automatically open an error page which you can't leave. Or you can leave that page but not the previous page. Anyway the navigation is broken now.

Link to public reproduction project repository

https://github.com/AlphaNERD-/MAUIPageNotClosingDemo

Version with bug

8.0.71 SR7.1

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 14

Did you find any workaround?

No response

Relevant log output

No response

AlphaNERD- avatar Aug 13 '24 09:08 AlphaNERD-

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

github-actions[bot] avatar Aug 13 '24 09:08 github-actions[bot]

I can repro this issue at android platform on the latest 17.11.0 Preview 7.0 (8.0.80 & 8.0.70) MAUIPageNotClosingDemo-main.zip

ninachen03 avatar Aug 13 '24 10:08 ninachen03

A few things here

  1. You don't need to wrap every single page in a NavigationPage. You probably only need the root page to be wrapped into a root page

  2. The reason that middle page is blank is most likely due to the fact that you're performing the push from inside a "Task". That's going to schedule that work off the dispatcher thread which is going to act in a somewhat undefined way.

  3. If I change the code inside OnAppearing to use the Dipatcher it all operates in a much more expected way. Page2 is pushing Page3 and then Page3 now pushes the ErrorPage. So your navigation stack is "Page2/Page3/ErrorPage", pushing a page from appearing doesn't interrupt the other page from getting pushed. You would need to pop it before pushing it.

If I change Page3 to this

image

It all acts somewhat expected. All three pages get pushed onto the stack and then every time I click the back button OnAppearing fires on Page3 which then repushes the error page on the stack

PureWeen avatar Aug 26 '24 21:08 PureWeen

Hi @AlphaNERD-. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.