Skip to content

Commit cb61c08

Browse files
committed
Fix unclickable submenus on touchscreen tablet
It works by cancelling the onclick URL change for the current (bold) parent menu item. This matches the mobile experience. Touchscreens can now tap a menu to go there (preserving current UX), tap again to open the submenu, then tap the submenu item. Previous behavior with mice is unchanged.
1 parent 1917b49 commit cb61c08

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

js/menu.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ let activeDrawer // active dropdown nav link
2020

2121

2222
for (const el of itemsMenu) {
23-
el.addEventListener("click", () => {
23+
el.addEventListener("click", (e) => {
24+
if (e.target.parentNode === el && e.pointerType === "touch" && el.querySelector("a.active")) {
25+
e.preventDefault(); // Tapping active menu on touchscreen tablet should open menu, not click
26+
}
2427
if (isSmallScreen || 'ontouchstart' in document.documentElement) {
2528
// HANDLE ACTIVE LINKS IN DROPDOWN NAV
2629
// if no activeDrawer set then page was set in md logic

0 commit comments

Comments
 (0)