]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
fix: set a default for the current menu in Drilldown before it is used
authorNicolas Coden <nicolas@ncoden.fr>
Tue, 31 Jul 2018 22:26:31 +0000 (00:26 +0200)
committerNicolas Coden <nicolas@ncoden.fr>
Tue, 31 Jul 2018 22:26:31 +0000 (00:26 +0200)
`$currentMenu` is used by `_getMaxDims`.

Changes: move `$currentMenu` initialization to `_init()`

js/foundation.drilldown.js

index 7add792a188caecd9060fc8c674c19d8b918fbb8..9deaf3272f423641e005824f89f461e8d5f0fc54 100644 (file)
@@ -61,6 +61,11 @@ class Drilldown extends Plugin {
     this.$submenuAnchors = this.$element.find('li.is-drilldown-submenu-parent').children('a');
     this.$submenus = this.$submenuAnchors.parent('li').children('[data-submenu]').attr('role', 'group');
     this.$menuItems = this.$element.find('li').not('.js-drilldown-back').attr('role', 'treeitem').find('a');
+
+    // Set the main menu as current by default (unless a submenu is selected)
+    // Used to set the wrapper height when the drilldown is closed/reopened from any (sub)menu
+    this.$currentMenu = this.$element;
+
     this.$element.attr('data-mutate', (this.$element.attr('data-drilldown') || GetYoDigits(6, 'drilldown')));
 
     this._prepareMenu();
@@ -128,10 +133,6 @@ class Drilldown extends Plugin {
     // set wrapper
     this.$wrapper = this.$element.parent();
     this.$wrapper.css(this._getMaxDims());
-
-    // Set the main menu as current by default (unless a submenu is selected)
-    // Used to set the wrapper height when the drilldown is closed/reopened from any (sub)menu
-    this.$currentMenu = this.$element;
   }
 
   _resize() {