From 8a563ca51ee38dcde4708ed694700c53d2e949ea Mon Sep 17 00:00:00 2001 From: Corban-Lee Jones Date: Mon, 14 Oct 2024 23:26:47 +0100 Subject: [PATCH] close theme dropmenu when sidebar collapses --- apps/home/static/home/js/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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"); + } });