Skip to content

fix: Empty Href behavior not consistent between NavLink and FluentNavLink #1654

@Hwiet

Description

@Hwiet

🐛 Bug Report

FluentNavLink does not create a link when the Href parameter is empty.

This is different from the expected behavior of NavLink component that comes with the Blazor framework, where an empty Href creates a link to the root of the application. In an unmodified Blazor WebAssembly Standalone App template available on Visual Studio, this is how the link to the root of the application is written in NavMenu.razor:

 <div class="nav-item px-3">
     <NavLink class="nav-link" href="" Match="NavLinkMatch.All">
         <span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Home
     </NavLink>
 </div>
 <div class="nav-item px-3">
     <NavLink class="nav-link" href="counter">
         <span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Counter
     </NavLink>
 </div>

...the link does not work anymore after switching NavLink to FluentNavLink.

This is not a big issue as passing ./ to the Href parameter seems to achieve the same result but it would be better if the behavior of FluentNavLink matches that of NavLink.

🤔 Expected Behavior

An empty string passed to the Href parameter of FluentNavLink should create a link to the root of the Blazor application.

😯 Current Behavior

An empty string passed to the Href parameter of FluentNavLink does not create a link at all.

💁 Possible Solution

Remove the !string.IsNullOrEmpty(Href) condition on FluentNavLink.razor

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions