Skip to content

Commit

Permalink
fix: only allow one top level nav item to be open at a time while ren…
Browse files Browse the repository at this point in the history
…dering as a dropdown menu
  • Loading branch information
bolt-bot committed Apr 25, 2020
1 parent d0155b5 commit 409bef3
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion packages/uikit-workshop/src/scripts/components/pl-nav/pl-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,22 @@ class Nav extends BaseComponent {

toggleNavPanel(e) {
const target = e.target;
target.classList.toggle('pl-is-active');

// when the Nav renders as a dropdown menu, only allow one menu to be open at a time to prevent overlap
if (this.layoutMode !== 'vertical' && window.innerWidth > 670) {
target.classList.toggle('pl-is-active');

this.topLevelTriggers = document.querySelectorAll(
'.pl-c-nav__link--title.pl-is-active'
);

this.topLevelTriggers.forEach(trigger => {
if (trigger !== target) {
trigger.classList.remove('pl-is-active');
trigger.nextSibling.classList.remove('pl-is-active');
}
});
}
}

rendered() {
Expand Down

0 comments on commit 409bef3

Please sign in to comment.