Coder Social home page Coder Social logo

Comments (7)

bkaankose avatar bkaankose commented on July 24, 2024

For me even "../NewPage" does not work. I want existing page to be removed from the stack, and new NewPage is pushed to the stack.

NavigationService simply ignores all 'remove from the stack' requests and just pushes a new NewPage on top of the current stack.

from prism.

lucacivale avatar lucacivale commented on July 24, 2024

For me even "../NewPage" does not work. I want existing page to be removed from the stack, and new NewPage is pushed to the stack.

NavigationService simply ignores all 'remove from the stack' requests and just pushes a new NewPage on top of the current stack.

In my repro that seems to work. Can you verify that?

from prism.

bkaankose avatar bkaankose commented on July 24, 2024

For me even "../NewPage" does not work. I want existing page to be removed from the stack, and new NewPage is pushed to the stack.
NavigationService simply ignores all 'remove from the stack' requests and just pushes a new NewPage on top of the current stack.

In my repro that seems to work. Can you verify that?

Yes it works on your repro. I guess my situation is different since I have a complex page construction.

1 - FlyoutPage/NavigationPage/TabbedPage (tabs generated dynamically using KnownNavigationParameters.CreateTab)
2 - One of the tabs inside TabbedPage navigates to PageA
3 - Then PageA goes to PageB by (../PageB).

What works in Xamarin is on PageB go back takes me directly to TabbedPage. In MAUI we go back to PageA, which should've been removed from the stack on step 3.

from prism.

Alex-Dobrynin avatar Alex-Dobrynin commented on July 24, 2024

@bkaankose @lucacivale

For me even "../NewPage" does not work. I want existing page to be removed from the stack, and new NewPage is pushed to the stack.

You should take into consideration that if your root is not NavigationPage then you don't have navigation stack. To have an ability do ../PageB when you have root PageA, your PageA should be the root of NavigationPage. In other words, you should have NavigationPage/PageA if you want to do ../PageB

Also you need to remember, that by the logic your NavigationPage cannot be empty (when it does not have root page). Because it does not have any sense in such implementation. And whenever you need an empty NavigationPage you have to think about your architecture and may be smth wrong with it

from prism.

bkaankose avatar bkaankose commented on July 24, 2024

@bkaankose @lucacivale

For me even "../NewPage" does not work. I want existing page to be removed from the stack, and new NewPage is pushed to the stack.

You should take into consideration that if your root is not NavigationPage then you don't have navigation stack. To have an ability do ../PageB when you have root PageA, your PageA should be the root of NavigationPage. In other words, you should have NavigationPage/PageA if you want to do ../PageB

Also you need to remember, that by the logic your NavigationPage cannot be empty (when it does not have root page). Because it does not have any sense in such implementation. And whenever you need an empty NavigationPage you have to think about your architecture and may be smth wrong with it

My navigation stack is inside the Flyout's content. So there is a stack, even though the app does not start with NavigationPage, but instead starts with FlyoutPage/NavigationPage.

This exact code used to work with Prism.Forms btw. This is a %100 migration work. This clearly shows that something changed in PageNavigationService and uri parser that it ignores this remove instruction segment.

I haven't find time to debug myself yet tough unfortunately. I'll check myself when I do.

from prism.

lucacivale avatar lucacivale commented on July 24, 2024

I debugged this issue and think I found the issue.
The navigation won't work because NavigateAsync and GoBackAsync consume a request in the SemaphoreSlim and therefore the GoBackAsnyc won't finish if the navigation tries to remove pages and go back.
As far as I understand the GoBackAsync doesn't need to wait for the Semaphore in this context. Can we split the GoBackAsync in two separate methods? The GoBackAsync will wait for the Semaphore and call the GoBackInternalAsync. GoBackInternalAsync processes the navigation. The RemoveAndGoBack could call the GoBackInternalAsync and the issue should be resolved and it's ensured that only one navigation is done simultaneously.
I could create a PR for this if I get some feedback from @dansiegel or @brianlagunas

@bkaankose couldn't repro your case. I created the Tab with the NavigationBuilder and the ../PageB worked properly.

from prism.

dansiegel avatar dansiegel commented on July 24, 2024

@lucacivale thanks for stepping up to help out. We would be more than happy to get your PR. A couple of keys to consider here...

  1. The SemaphoreSlim was added due to solve the issue that if you have something like a 'LoadingPage' where you might evaluate the state of the user and you might then navigate to the 'LoginPage' or the 'HomePage' from the OnNavigatedTo. This would fail because the Navigation to the 'LoadingPage' did not yet complete.
  2. We will require one or more tests as makes sense for the scenario(s) you've uncovered. It would be good to have them start with Issue3047_ so that we can always track the issue back to this GitHub Issue.
  3. You may want to start with adding the tests first to validate that they are failing now and that your changes fix the issue. If you have any additional questions let me know.

from prism.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.