Blazorise: SidebarSubItem expand when you navigate away from it

Created on 18 Nov 2019  路  10Comments  路  Source: stsrki/Blazorise

Describe the bug
The subitem expands when you navigate away from it.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://materialdemo.blazorise.com/
  2. Click on 'Test Pages'. The subitem 'Test Pages' collapses.
  3. Click on 'Dashboard'. The subitem 'Test Pages' expands.

Expected behavior
The subitem 'Test Pages' shouldn't expand when you navigate away from it.
This issue occurs in my application too, not only in the demo page.

Most helpful comment

The problem is in the IsShow where it's always set to true. I will fix it.

<SidebarLink Toggled="(isOpen)=> sidebarSubItemTests.Toggle(isOpen)" IsShow="true">
    <Icon Name="IconName.Edit" Margin="Margin.Is3.FromRight" />Test Pages
</SidebarLink>

All 10 comments

When I use the sidebar It shows like this:

image

Could you help me?

@OscarCanek Have you included sidebar.css into your index.html or _Host.cshtml?

eg.

<link href="_content/Blazorise.Sidebar/blazorise.sidebar.css" rel="stylesheet" />

PS. FYI if you want to ask questions in the future please open new issue. tnx

If it helps, expanding the subitem, clicking on an item inside it, and then clicking on an item not inside that subitem won't collapse the subitem.

The problem is in the IsShow where it's always set to true. I will fix it.

<SidebarLink Toggled="(isOpen)=> sidebarSubItemTests.Toggle(isOpen)" IsShow="true">
    <Icon Name="IconName.Edit" Margin="Margin.Is3.FromRight" />Test Pages
</SidebarLink>

@stsrki did you fix this?

This is a workaround:

<SidebarLink Toggled="(isOpen)=> { SidebarSubItemOthersShow = isOpen; SidebarSubItemOthers.Toggle(isOpen); }" IsShow="@SidebarSubItemOthersShow">

And to base class add:

        protected bool SidebarSubItemOthersShow { get; set; }

will leave this open in case you want to change it internally to the component

@WillianGruber Sorry for answering before. I'm on a business trip and doing meetings all day. It's great you managed to come up with solution.

Nice, I hope it all goes well.
About this subject, if the way I did it is the intended way, we I can close this issue

Sure, this is actually a preferred way of doing it.

Ok, closing. Thanks

Was this page helpful?
0 / 5 - 0 ratings