Skip to content

Blazor: expose 'replace' parameter in NavigationManager.NavigateTo #25540

Closed
@zbecknell

Description

@zbecknell

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

I want to maintain some of my view state in the URL, such as the currently selected tab. I can and do use window.history.replaceState for this, but the NavigationManager.Uri is then out of sync. I'd like to be able to keep the Uri in sync, as I'm using it to help manage this state. I need to get the Uri synchronously so I can't just call location.href using interop.

Describe the solution you'd like

Simple option

I believe the simplest solution would be to make NavigationManager.Uri settable publicly so I can then perform this task myself. I don't want to have to implement my own NavigationManager just for this purpose. It is already clear in the docs that setting Uri doesn't trigger LocationChanged, which again, is my desired behavior, so hopefully making this public isn't too big of a concern.

Fancier option

The other option is to expose the replace that already exists in navigateTo() in NavigationManager.ts. However... I don't want to trigger OnParametersSet in my scenario, and I think this would do so by default. Personally, I'd like to submit a PR for the first option and leave this one on the table.

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected-fewThis issue impacts only small number of customersarea-blazorIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-blazor-builtin-componentsFeatures related to the built in components we ship or could ship in the futurehelp wantedUp for grabs. We would accept a PR to help resolve this issueseverity-majorThis label is used by an internal tool

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions