Skip to content

Sidebar auto-collapses any collapsable children on wide media - fix included #5590

@GodzillaDaThrilla

Description

@GodzillaDaThrilla

Figured this out while trying to create an accordion on the sidebar. I found that the standard bootstrap collapse on child elements worked fine on small screens where the sidebar collapses to the top, but on large screens the accordion menu(s) would just keep re-collapsing (again, only only large screens, collapseable elements functioned normally in mobile view).

The Problem:

The problem is with the default template, specifically this in NavMenu.cshtml:
image
and this in site.css:
image

This means that the collapse prevention is inherited by all child elements on wide screens, which makes a hamburger/accordion-style menu impossible.

The Fix:

Add an arbitrary class to the HTML - I called mine navInner:
image
Then modify the CSS so it targets only the sidebar specifically and not its children. I did this by replacing the ".collapse" with a combo-selector ".navInner.collapse" :
image

The Result:

image
image
Hey hey, it works!

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected-very-fewThis issue impacts very few customersarea-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.feature-templatesseverity-minorThis label is used by an internal tool

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions