Skip to content

Commit 3db15d2

Browse files
authored
Fix top menu collapsing issue (#2820)
- Fix top menu collapsing when opening dialog windows on mobile. - Fix top menu not collapsing when switching from mobile to desktop.
1 parent 12eb2cf commit 3db15d2

4 files changed

Lines changed: 14 additions & 7 deletions

File tree

css/style.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,15 @@ div#tadd {max-width: 95vw;}
643643
/* Medium devices (tablets, 768px and up) */
644644
@media (min-width: 768px) {
645645
/* Custom rules for medium devices */
646+
#top-menu.collapsing {
647+
/*
648+
prevent top menu blinking when:
649+
1) switching from mobile to desktop
650+
AND
651+
2) the collapsible menu was open before switching.
652+
*/
653+
display: none !important;
654+
}
646655
#t .nav-link:hover {
647656
background: transparent url(../images/tb_bg.gif) no-repeat scroll left center;
648657
filter: none;

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
<div class="navbar-toggler-icon"></div>
8787
</button>
8888
</div>
89-
<div class="collapse navbar-collapse px-1 py-2 py-md-0" id="top-menu">
89+
<div class="collapse navbar-collapse px-1 py-2 py-md-0" id="top-menu" data-bs-toggle="false">
9090
<div class="navbar-nav flex-grow-1">
9191
<div class="d-flex flex-row align-items-center flex-wrap flex-md-nowrap">
9292
<a id="mnu_add" class="nav-link flex-grow-1" href="#" onclick="theWebUI.showAdd(); return(false);" onfocus="this.blur()" uilangtitle="mnu_add">

js/objects.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,9 @@ var theDialogManager = {
208208
// Close side panel on mobile:
209209
// An offcanvas is a modal under the hood and will intercept focus events
210210
// from other elements, and make other text inputs unfocusable and uneditable.
211-
bootstrap.Offcanvas.getOrCreateInstance(document.querySelector("#offcanvas-sidepanel")).hide();
211+
bootstrap.Offcanvas.getInstance("#offcanvas-sidepanel")?.hide();
212212
// close collapsible top menu on opening dialog windows
213-
bootstrap.Collapse.getOrCreateInstance("#top-menu").hide();
213+
bootstrap.Collapse.getInstance("#top-menu")?.hide();
214214
}
215215

216216
const obj = $('#' + id);

js/webui.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2306,10 +2306,8 @@ var theWebUI =
23062306
theWebUI.resizeTop(null, h);
23072307
// center any open dialog
23082308
theDialogManager.visible.forEach(id => theDialogManager.center(id));
2309-
if ($(window).width < 768) {
2310-
// close collapsible top menu
2311-
bootstrap.Collapse.getOrCreateInstance("#top-menu").hide();
2312-
}
2309+
// close collapsible top menu
2310+
bootstrap.Collapse.getInstance("#top-menu")?.hide();
23132311
},
23142312

23152313
update: function()

0 commit comments

Comments
 (0)