dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.13k stars 9.91k forks source link

Navigation with stack #49948

Open timdinh opened 1 year ago

timdinh commented 1 year ago

Is there an existing issue for this?

Is your feature request related to a problem? Please describe the problem.

In blazor, I have a parent and a child page, when we go back to parent from the child, the parent page get reconstruct and we lose the scroll position and there is a performance penalty for reconstructing the page.

Describe the solution you'd like

My proposal is that when navigating to the child view, it should be placed on top of the parent view like a stack. When we navigate back, all we have to do is remove the child view. This way, there is no performance penalty due to having parent page reconstruct again and we don't lose scrolling position.

Disadvantage would be if the app has very deep navigation stack then it would use more memory. However, most app don't have very deep navigation. Also, the developer would have a choice of weather they want to use current Navigation or the new StackNavigation

Additional context

No response

Markz878 commented 1 year ago

It's not really clear what you mean by parent/child page, this is not a generally understood concept in blazor, can you please provide a minimal repro of what you mean? Is this related to SSR pages or SPA type applications?

ghost commented 1 year ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

timdinh commented 1 year ago

Here's a diagram that should help explain.

Presentation1

iOS navigation is doing something similar, it just has a stack and it place child view on top and remove the last view when user navigate back.

gragra33 commented 1 year ago

@timdinh

If you're using .Net 7.0 or earlier, check out Jeremy Likness' blog post Blazor State Management

If .Net 8.0 (Preview), Dan Roth has an excellent sample project on Github: BestForYouRecipes

Hopefully these help.