FluentNavItem in hamburger drawer triggers duplicate navigation and breaks NavigationLock confirmation

Open
#5,707 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
frontend

Research direction

Start by reading FluentNavItem.OnClickHandlerAsync, which the issue identifies as closing the hamburger drawer and calling NavigationManager.NavigateTo(Href) while the item also renders as a link. Reproduce the two NavigationLock callbacks with deferred navigation and an open drawer, then trace how the link and drawer click handlers interact. Done means one navigation request reaches the confirmation callback, with OK navigating and Cancel keeping the current page open.

Written by the indexing model from the issue text.

Description

🐛 Bug Report

FluentNavItem inside an open FluentLayoutHamburger drawer appears to trigger navigation twice. This prevents an unsaved-changes confirmation using Blazor's NavigationLock from reliably allowing navigation when the user selects primary.

💻 Repro or Code Sample

  1. Configure a FluentLayout with NavigationDeferredLoading="true".
  2. Add a FluentLayoutHamburger and a FluentNav containing a FluentNavItem with a relative Href to the layout's navigation area.
  3. On a page with unsaved changes, use a NavigationLock to ask the user to confirm before navigating.
  4. Open the hamburger drawer and click a navigation item.
  5. In the OnBeforeInternalNavigation callback, observe two calls for the same destination:
    • TargetLocation: http://localhost:10000/target, IsNavigationIntercepted: true
    • TargetLocation: target, IsNavigationIntercepted: false

Relevant layout pattern:

<FluentLayout NavigationDeferredLoading="true">
    <FluentLayoutItem Area="LayoutArea.Header">
        <FluentLayoutHamburger Display="HamburgerDisplay.DesktopMobile" />
    </FluentLayoutItem>

    <FluentLayoutItem Area="LayoutArea.Navigation">
        <FluentNav>
            <FluentNavItem Href="target">
                Target
            </FluentNavItem>
        </FluentNav>
    </FluentLayoutItem>
</FluentLayout>

The page registers a NavigationLock while it has unsaved changes.

🤔 Expected Behavior

Clicking a navigation item in the drawer should trigger one navigation request and one confirmation dialog. OK should navigate to the selected page; Cancel should keep the current page open.

😯 Current Behavior

The location-changing callback is invoked twice for the same destination: once for an intercepted link navigation and once for a programmatic navigation using the relative Href.

If the application prevents a second confirmation dialog while the first is open, the second navigation request can be canceled or supersede the first. As a result, selecting OK does not reliably navigate.

💁 Possible Solution

Ensure that drawer navigation uses only one navigation path. FluentNavItem.OnClickHandlerAsync closes an open hamburger and then calls NavigationManager.NavigateTo(Href), while the item is also rendered as a link.

Could the normal link navigation and the drawer-specific programmatic navigation be made mutually exclusive?

🔦 Context

This affects navigation away from pages with unsaved changes. The application uses NavigationLock to let users either discard their changes and proceed or cancel navigation.

🌍 Your Environment

  • OS & Device: Windows PC 10.0.26100 build 26100
  • Browser: Microsoft Edge 158.0.4370.45
  • .NET and Fluent UI Blazor library Version: .NET 10, Microsoft.FluentUI.AspNetCore.Components 5.0.0
  • Blazor render mode: Interactive Server
Dominant language
C#
Stars
4.9k
Forks
500
Avg merge
15h 28m
Merged PRs (30d)
58

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/fluentui-blazor

All issues in microsoft/fluentui-blazor

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.