Skip to content

Fix unclickable submenus on touchscreen tablet#1983

Merged
bjohansebas merged 2 commits intoexpressjs:gh-pagesfrom
danielzgtg:fix/touchscreenNav
Aug 1, 2025
Merged

Fix unclickable submenus on touchscreen tablet#1983
bjohansebas merged 2 commits intoexpressjs:gh-pagesfrom
danielzgtg:fix/touchscreenNav

Conversation

@danielzgtg
Copy link
Copy Markdown
Contributor

@danielzgtg danielzgtg commented Jul 22, 2025

Fixes: #1170

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.

Before

before

After

after

@danielzgtg danielzgtg requested a review from a team as a code owner July 22, 2025 22:52
@netlify
Copy link
Copy Markdown

netlify Bot commented Jul 22, 2025

Deploy Preview for expressjscom-preview ready!

Name Link
🔨 Latest commit 82ed780
🔍 Latest deploy log https://app.netlify.com/projects/expressjscom-preview/deploys/6885b72a5bd3430008ec8122
😎 Deploy Preview https://deploy-preview-1983--expressjscom-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@danielzgtg danielzgtg marked this pull request as draft July 22, 2025 22:57
@danielzgtg danielzgtg marked this pull request as ready for review July 22, 2025 23:20
Copy link
Copy Markdown
Member

@ShubhamOulkar ShubhamOulkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comment below.

I’d like to highlight that, by default, :hover events generally do not fire on touchscreen devices, as there's no concept of "hover" with touch — users either tap or don’t. This behavior is documented on MDN.

However, some hybrid devices (like the Microsoft Surface) may trigger hover events when using a mouse or trackpad — but not via touch.

To ensure consistent interactivity across all devices, we should either:

- reuse/modify the existing click event from menu.js for both desktop and mobile, or

- add support for touch events where needed.

Note: We doing redesign of top navigation bar, this issue will get removed there.

Comment thread _includes/header.html Outdated
@danielzgtg
Copy link
Copy Markdown
Contributor Author

by default, :hover events generally do not fire on touchscreen devices

In addition to the tablet, hover events work on my Android phone using both Chrome and Firefox.

we should either

I finally found the listener on menu.js:23. Tomorrow, I will:

  • Revert the HTML changes
  • Split the bold fixes into another PR
  • preventDefault for non-mouse pointerType after line 23

@danielzgtg danielzgtg force-pushed the fix/touchscreenNav branch 2 times, most recently from efa0fb6 to e5e8374 Compare July 23, 2025 20:59
@danielzgtg danielzgtg requested a review from ShubhamOulkar July 23, 2025 21:00
Comment thread js/menu.js Outdated
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.
@danielzgtg danielzgtg force-pushed the fix/touchscreenNav branch from e5e8374 to cb61c08 Compare July 27, 2025 05:09
Comment thread js/menu.js
Copy link
Copy Markdown
Member

@ShubhamOulkar ShubhamOulkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
🎉 awesome shout-out to @danielzgtg! 🙌

Copy link
Copy Markdown
Member

@bjohansebas bjohansebas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't reproduce it, but if the error is fixed, it's fine by me. I don't have a tablet, and on the phone the size isn't enough to check it. The code looks fine.

LGTM

@bjohansebas bjohansebas merged commit abee42a into expressjs:gh-pages Aug 1, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dropdowns missing on touchscreen tablet

3 participants