close theme dropmenu when sidebar collapses

This commit is contained in:
Corban-Lee Jones 2024-10-14 23:26:47 +01:00
parent 2571630c41
commit 8a563ca51e

View File

@ -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");
}
});