Skip to content

Commit

Permalink
Adds the active class to the last trail element if no active one was …
Browse files Browse the repository at this point in the history
…found (#58)
  • Loading branch information
rabauss authored Dec 29, 2020
1 parent 57e92ed commit 1aea0b7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Resources/contao/templates/mmenu_default.html5
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ if ($this->options['drag']['menu']['open']) {
<script>
document.addEventListener(
"DOMContentLoaded", function () {
const menu = document.querySelector('#<?= $this->elementId ?>');
if (null !== menu && 0 === menu.querySelectorAll('li.submenu.active').length) {
const trails = menu.querySelectorAll('li.submenu.trail');
if (0 < trails.length) {
trails.item(trails.length - 1).classList.add('active');
}
}
new Mmenu('#<?= $this->elementId ?>', <?= json_encode($this->options) ?>, <?= json_encode($this->configuration) ?>);
}
);
Expand Down

0 comments on commit 1aea0b7

Please sign in to comment.