Files
T
cgalo5758 3283df19b1 Move account menu into mobile rail drawer
Below lg the top bar now holds the brand and one toggler; the account
items render in the drawer as a second, labelled list from a shared
partial, so both surfaces cannot drift. Desktop unchanged.
2026-09-09 22:57:26 -05:00

32 lines
1.5 KiB
JavaScript

// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
// SPDX-FileCopyrightText: 2025-2026 Christian Galo
// Application shell (docs/design-system.md, "Application shell"): close the
// rail drawer when one of its entries is chosen. Below lg the drawer is the
// shell's one menu, so its entries are the task destinations, the surface
// switch, and the account menu's links; the two account links open a new
// tab, and closing the drawer behind them is what the person coming back
// expects. Sign out is a <button>, not an anchor, so it never matches here;
// its handler answers with HX-Redirect.
//
// Below the lg breakpoint the rail (#app-rail) is a Bootstrap offcanvas. On
// the operator surface its entries navigate under hx-boost, which swaps the
// body but leaves Bootstrap's scroll lock on <body> behind unless the drawer
// is hidden first; on the member surface a full page load follows and this
// is a harmless no-op. Bootstrap's own data-bs-dismiss cannot go on the
// links: it cancels an anchor's navigation. This file is external because
// the content security policy forbids inline scripts.
(function () {
document.addEventListener('click', function (event) {
var link = event.target.closest('#app-rail a[href]');
if (!link || typeof bootstrap === 'undefined') {
return;
}
var rail = document.getElementById('app-rail');
var drawer = rail && bootstrap.Offcanvas.getInstance(rail);
if (drawer) {
drawer.hide();
}
});
})();