Issue #3221871 by mherchel, Gauravmahlawat, W01F, nod_: Olivero: Mobile menu prevents scroll & obscures page after click if menu item contains link to anchor on same page
(cherry picked from commit 4f8c468f10
)
merge-requests/1102/head
parent
f67186647a
commit
d831b94304
|
@ -21,3 +21,8 @@ olivero_test.child_button:
|
||||||
parent: olivero_test.button
|
parent: olivero_test.button
|
||||||
menu_name: main
|
menu_name: main
|
||||||
weight: 100
|
weight: 100
|
||||||
|
olivero_test.anchor_link:
|
||||||
|
title: "⚓️ Anchor link"
|
||||||
|
url: "internal:#footer"
|
||||||
|
menu_name: main
|
||||||
|
weight: 200
|
||||||
|
|
|
@ -163,4 +163,13 @@ module.exports = {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
'Verify clicks on hashes close mobile menu': (browser) => {
|
||||||
|
browser
|
||||||
|
.drupalRelativeURL('/node')
|
||||||
|
.waitForElementVisible('body')
|
||||||
|
.click(mobileNavButtonSelector)
|
||||||
|
.waitForElementVisible(headerNavSelector)
|
||||||
|
.click('[href="#footer"]')
|
||||||
|
.waitForElementNotVisible(headerNavSelector);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -113,6 +113,18 @@
|
||||||
// Ensure that all sub-navigation menus close when the browser is resized.
|
// Ensure that all sub-navigation menus close when the browser is resized.
|
||||||
Drupal.olivero.closeAllSubNav();
|
Drupal.olivero.closeAllSubNav();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// If hyperlink links to an anchor in the current page, close the
|
||||||
|
// mobile menu after the click.
|
||||||
|
props.navWrapper.addEventListener('click', (e) => {
|
||||||
|
if (
|
||||||
|
e.target.matches(
|
||||||
|
`[href*="${window.location.pathname}#"], [href*="${window.location.pathname}#"] *, [href^="#"], [href^="#"] *`,
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
toggleNav(props, false);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -73,6 +73,11 @@
|
||||||
|
|
||||||
Drupal.olivero.closeAllSubNav();
|
Drupal.olivero.closeAllSubNav();
|
||||||
});
|
});
|
||||||
|
props.navWrapper.addEventListener('click', function (e) {
|
||||||
|
if (e.target.matches("[href*=\"".concat(window.location.pathname, "#\"], [href*=\"").concat(window.location.pathname, "#\"] *, [href^=\"#\"], [href^=\"#\"] *"))) {
|
||||||
|
toggleNav(props, false);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Drupal.behaviors.oliveroNavigation = {
|
Drupal.behaviors.oliveroNavigation = {
|
||||||
|
|
Loading…
Reference in New Issue