<SfSidebar Width="250px" DockSize="72px" EnableDock="true" Position="@SidebarPosition.Left" HtmlAttributes="@_htmlAttribute" @bind-IsOpen="SidebarCommonOptions.IsSidebarDocked" Type="SidebarType.Push" MediaQuery="(min-width: 1200px)" EnableGestures="true" EnablePersistence="true" Target=".maincontent" >
</SfSidebar>
Hello I have this sidebar code but the persistence doesn't seem to work. If I dock the sidebar and refresh, it is always open.
Hi Pavel,
Greetings from Syncfusion support.
We have validated the reported issue at your end with the shared code snippet. We have identified that the reported issue occurs due to the MediaQuery property. This will open the sidebar component only when the provided resolution is met; else the sidebar will be in a closed state. So the persistence state is not maintained, since the mentioned resolution is met with MediaQuery. This is the property's behavior.
For your reference, we have shared a sample with MediaQuery removed. Please find the working sample from below link.
https://www.syncfusion.com/downloads/support/directtrac/general/ze/BlazorSidebar-1707147328
Note: The state of a component will be retained during navigation or refreshment based on the ID. Make sure to set an ID for the component to store the component’s state in the browser.
Please check the sample and let us know if you need any further assistance.
Regards,
Indhumathy L
I removed the MediaQuery property and added a ID to the sidenavigation. However the persistence is still not working.
I looked at the sample you shared, but it doesn't have
EnablePersistence="true"
property.
Can you please provide further assistance?
Hi Pavel,
In our previous shared sample, we rendered the Sidebar component in the MainLayout.razor page. We enabled the EnablePersistence property and it works properly. For your reference, we have recorded the behavior with the shared sample.
https://www.syncfusion.com/downloads/support/directtrac/general/ze/SidebarVideo-944035334
We suspect that the issue may occur due to a cache issue. Try following the below blog to clear the cache and run the above shared sample.
https://www.syncfusion.com/kb/6987/how-to-clear-nuget-cache
If the issue still persists, please share us the simple issue reproduced sample with the exact package version used at your end. Please try the suggested way and get back to us if you need any further assistance.
Regards,
Indhumathy L