Fix that navbar forgets active state after refresh (#4831)
This commit is contained in:
parent
8e64c0b239
commit
3482ef9e65
|
@ -31,8 +31,6 @@ class ConfigMenu extends BaseHtmlElement
|
|||
|
||||
protected $selected;
|
||||
|
||||
protected $cogItemActive = false;
|
||||
|
||||
protected $state;
|
||||
|
||||
public function __construct()
|
||||
|
@ -143,10 +141,6 @@ class ConfigMenu extends BaseHtmlElement
|
|||
),
|
||||
$this->createLevel2Menu()
|
||||
]);
|
||||
|
||||
if ($this->cogItemActive) {
|
||||
$cogMenuItem->addAttributes([ 'class' => 'active' ]);
|
||||
}
|
||||
}
|
||||
|
||||
protected function assembleLevel2Nav(BaseHtmlElement $level2Nav)
|
||||
|
@ -275,7 +269,6 @@ class ConfigMenu extends BaseHtmlElement
|
|||
|
||||
if ($this->isSelectedItem($item)) {
|
||||
$li->addAttributes(['class' => 'selected']);
|
||||
$this->cogItemActive = true;
|
||||
}
|
||||
|
||||
return $li;
|
||||
|
|
|
@ -222,13 +222,15 @@
|
|||
|
||||
Navigation.prototype.setActiveAndSelected = function ($el) {
|
||||
if ($el.length > 1) {
|
||||
$el.each(el => {
|
||||
$el.each((key, el) => {
|
||||
if (! this.active) {
|
||||
this.setActiveAndSelected($(el));
|
||||
}
|
||||
});
|
||||
} else if ($el.length) {
|
||||
if ($el[0].offsetWidth || $el[0].offsetHeight || $el.closest('.config-menu').length) {
|
||||
let parent = $el[0].closest('.nav-level-1 > .nav-item, .config-menu');
|
||||
|
||||
if ($el[0].offsetHeight || $el[0].offsetWidth || parent.offsetHeight || parent.offsetWidth) {
|
||||
// It's either a visible menu item or a config menu item
|
||||
this.setActive($el);
|
||||
this.setSelected($el);
|
||||
|
|
Loading…
Reference in New Issue