Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Implement NavigationManager.NavigateToAsync #64813

@mrpmorris

Description

@mrpmorris

Is there an existing issue for this?

  • I have searched the existing issues

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

A client I am working for has a LayoutComponent that has various data functions such as CRUD + Search. Upon selecting an object to edit it uses NavigationManager to navigate.

Once the child content has updated, the layout needs to update its state. However, we cannot wait until the navigation is complete because NavigateTo is synchronous.

The navigation process might take a long time due to a modal "Do you want to cancel your changes" confirmation that is hooked into NavigationManager.RegisterLocationChangingHandler.

Describe the solution you'd like

Request 1

I wrote something myself, but it isn't ideal. My biggest problem is not being able to know if the navigation has been cancelled so that I can cancel the task immediately. Could we have a "Task NavigationCancelled" property on LocationChangingContext?

Request 2

Add NavigateToAsync overloads to NavigationManager.

I'm not sure at which point the task should be marked as completed

  1. After all LocationChangingHandlers have approved?
  2. After LocationChanged event has fired?
  3. After LocationChanged event + the page SetParametersAsync has first completed?
  4. Something else?

Option 2 might be best?

Additional context

Not sure how this would work with a page's IDisposable.Dispose being called whilst it navigates asynchronously to another page and awaits the result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor Components

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions