From f943c10318962597a2eea594a62bd619ee1a1286 Mon Sep 17 00:00:00 2001 From: Francisco Date: Thu, 31 Aug 2023 22:09:39 -0300 Subject: [PATCH] Allow expanding sidebar by clicking on non-links (#370) --- ui/src/css/specific/navigation.scss | 7 +++---- ui/src/js/05-sidr-menu.js | 7 ++++--- ui/theme/partials/navigation-tree.hbs | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ui/src/css/specific/navigation.scss b/ui/src/css/specific/navigation.scss index 0fa9d0b7..921fac3d 100644 --- a/ui/src/css/specific/navigation.scss +++ b/ui/src/css/specific/navigation.scss @@ -78,10 +78,9 @@ font-size: 1rem; } -.nav-li { - a:hover { - opacity: .8; - } +.nav-link:hover { + opacity: .8; + cursor: pointer; } .nav-link code { diff --git a/ui/src/js/05-sidr-menu.js b/ui/src/js/05-sidr-menu.js index 70ba4b16..8d460519 100644 --- a/ui/src/js/05-sidr-menu.js +++ b/ui/src/js/05-sidr-menu.js @@ -21,9 +21,10 @@ if (isDefaultCollapsed && !o.parentElement.classList.contains('nav-li-active-parent')) { o.classList.toggle('toggled'); } - o.addEventListener('click', function (e) { - this.classList.toggle('toggled'); - }); + const toggle = () => o.classList.toggle('toggled'); + o.addEventListener('click', toggle); + const span = [...o.parentElement.children].find(c => c.matches('span.nav-link')); + span?.addEventListener('click', toggle); }); // The preinit class sets up collapsed states before JS executes to avoid flashing uncollapsed menu diff --git a/ui/theme/partials/navigation-tree.hbs b/ui/theme/partials/navigation-tree.hbs index f6bf7daf..e69cdc23 100644 --- a/ui/theme/partials/navigation-tree.hbs +++ b/ui/theme/partials/navigation-tree.hbs @@ -7,7 +7,7 @@ {{{content}}} {{else}} - {{#if content}}{{{content}}}{{/if}} + {{#if content}}{{{content}}}{{/if}} {{/if}} {{!-- Nesting --}} {{#if items}}