dotnet / dotnet/aspnetcore

Feature Request - Option for Blazor's `NavigationManager.NavigateTo` to halt additional processing

Open
#23,960 4 comments 3 reactions 0 assignees View on GitHub
affected-very-few area-blazor enhancement feature-blazor-builtin-components severity-minor
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

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

I'm trying to handle a default route parameter. When no route parameter is given, I'd like to call `NavigationManager.NavigateTo` to add a default route parameter to the URI. Doing so will allow the appropriate `NavLink` to be given the `active` class.

Alternatively, if `NavLink` can be given 2 Match options, that would also solve it.

### A clear and concise description of what the problem is.

The issue with calling `NavigationManager.NavigateTo` is that processing continues for a bit. For example, if I call `NavigationManager.NavigateTo` in `OnInitialized`, `OnParametersSetAsync` will still be called, which can cause an error or perform unnecessary work that the user must wait on.

### Describe the solution you'd like
Either `NavigationManager.NavigateTo` could halt immediately and perform the route navigation, or `NavLink` could accept an additional `Match` value.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.