Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change onclick action in navigation for default template #51230

Closed
1 task done
Alerinos opened this issue Oct 9, 2023 · 1 comment
Closed
1 task done

Change onclick action in navigation for default template #51230

Alerinos opened this issue Oct 9, 2023 · 1 comment
Labels
area-blazor Includes: Blazor, Razor Components

Comments

@Alerinos
Copy link

Alerinos commented Oct 9, 2023

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.

Currently, the default blazor template for navigation uses javascript:

<div class="top-row ps-3 navbar navbar-dark">
    <div class="container-fluid">
        <a class="navbar-brand" href="">MyBlazorWeb</a>
    </div>
</div>

<input type="checkbox" title="Navigation menu" class="navbar-toggler" />

<div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()">
    <nav class="flex-column">
        <div class="nav-item px-3">
            <NavLink class="nav-link" href="" Match="NavLinkMatch.All">
                <span class="bi bi-house-door-fill" 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" aria-hidden="true"></span> Counter
            </NavLink>
        </div>

        <div class="nav-item px-3">
            <NavLink class="nav-link" href="weather">
                <span class="bi bi-list-nested" aria-hidden="true"></span> Weather
            </NavLink>
        </div>
    </nav>
</div>

Suggest you change it to event blazor and make @attribute. Why? Many people who modify the template get rid of this component by putting the navigation in MainLayout. Unfortunately, Layout is not dynamic by which interactivity does not work. I caught myself in this trap.
Other people also had similar problems #50712 #50724

For the WebAssembly template, I would put the navigation in Client and do the rendering on the client side. This will be the best example for newbies. Also, in MainLayout you can comment out the link to the documentation that tells us that server-side rendering doesn't work.

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Oct 9, 2023
@mkArtakMSFT
Copy link
Member

Thanks for contacting us. The current approach is intentional and it used to be a Blazor event handler in the past.

@mkArtakMSFT mkArtakMSFT closed this as not planned Won't fix, can't repro, duplicate, stale Oct 9, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Nov 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

No branches or pull requests

2 participants