Skip to content

Commit abee42a

Browse files
danielzgtgShubhamOulkarbjohansebas
authored
Fix unclickable submenus on touchscreen tablet (#1983)
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. Co-authored-by: ShubhamOulkar <[email protected]> Co-authored-by: bjohansebas <[email protected]>
1 parent f263365 commit abee42a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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)