diff --git a/apps/home/static/home/js/index.js b/apps/home/static/home/js/index.js index 49e11aa..2db301c 100644 --- a/apps/home/static/home/js/index.js +++ b/apps/home/static/home/js/index.js @@ -222,11 +222,18 @@ $(".sidebar-backdrop").on("click", () => setSidebarVisibility(false)); // Prevent sidebar from opening if the screen becomes larger then smaller again, while it's visible $(window).on('resize', () => { + const sidebarVisibility = getSidebarVisibility(); + // Can't pass conditional directly, causes flickering effect - if (getSidebarVisibility() && $(window).width() > 992) { + if (sidebarVisibility && $(window).width() > 992) { setSidebarPinned(false); setSidebarVisibility(false); } + + // Close the theme menu when the sidebar collapses offscreen + else if (!sidebarVisibility && $(window).width() <= 992) { + $(".js-themeMenuBtn").dropdown("hide"); + } });