This topic contains 1 reply, has 2 voices, and was last updated by Sean Sean 1 year, 5 months ago.

[Bug] Sidebar Collapse & Expand not persisting due to wrong cookie usage


  • itc
    Participant

    Posts: 9
    Member Reply #7588

    Sidebar collapse and expand are not persisting across requests.

    I believe this is due to the change in 4.5.1 – migrate to js.cookie.min.js plugin

    The way the cookie code is called has changed from the previous tool you used. However, your layout.js didn’t change accordingly (e.g. if ($.cookie) is now if (Cookies)).

    The correct code within layout.js should be:

    
    
    // Handles sidebar toggler
    var handleSidebarToggler = function () {
    var body = $('body');
    if (Cookies && Cookies.get('sidebar_closed') === '1' && App.getViewPort().width >= resBreakpointMd) {
    $('body').addClass('page-sidebar-closed');
    $('.page-sidebar-menu').addClass('page-sidebar-menu-closed');
    }
    
    // handle sidebar show/hide
    $('body').on('click', '.sidebar-toggler', function (e) {
    var sidebar = $('.page-sidebar');
    var sidebarMenu = $('.page-sidebar-menu');
    $(".sidebar-search", sidebar).removeClass("open");
    
    if (body.hasClass("page-sidebar-closed")) {
    body.removeClass("page-sidebar-closed");
    sidebarMenu.removeClass("page-sidebar-menu-closed");zz
    if (Cookies) {
    Cookies.set('sidebar_closed', '0');
    }
    } else {
    body.addClass("page-sidebar-closed");
    sidebarMenu.addClass("page-sidebar-menu-closed");
    if (body.hasClass("page-sidebar-fixed")) {
    sidebarMenu.trigger("mouseleave");
    }
    if (Cookies) {
    Cookies.set('sidebar_closed', '1');
    }
    }
    
    $(window).trigger('resize');
    });
    };
    
    

     

    See also: http://keenthemes.com/forums/topic/sidebar-collaps-expand/

    • This topic was modified 1 year, 6 months ago by  itc.
    Sean
    Sean
    Keymaster

    Posts: 4206
    Support Staff Reply #7617

    Hi :),

    Thanks for your feedback on this. We will check this further and fix it in the next update very soon.

    Thanks.

You must be logged in to reply to this topic.