I am using Inspinia theme, and have modified the theme so that it remembers the status of the left hand panel (i.e. the navigation bar) though cookies. So if it is collapsed, it will stay collapsed even after refresh or login. The same for when it is expanded.
The code is simple:
if (getCookie('toggleSideBarPrefs') === '0') {
$("body").addClass("mini-navbar");
} else {
$("body").removeClass("mini-navbar");
}
and I set the cookie when clicking the hamburger button:
$('.navbar-minimalize').on('click', function (event) { . . . }
Now this works, except when it is in collapsed mode, if I click on another icon on the panel, it first quickly expands it, then collapses it. This is very annoying. The main reason for this is that by default it is expanded (i.e no mini-navbar tag on body). Now if I add this tag by default, it will fix the problem when collapsed but the same problem will happen when in expanded mode.
Anyone can share some ideas please on how to fix this? I am new to front end development.
Thanks.