docs(topbar): tap-to-open Examples/Documentation dropdowns on touch#1993
Closed
zherendong wants to merge 1 commit into
Closed
docs(topbar): tap-to-open Examples/Documentation dropdowns on touch#1993zherendong wants to merge 1 commit into
zherendong wants to merge 1 commit into
Conversation
On touch / no-hover devices the desktop hover never fires, so the first tap on the Examples / Documentation trigger anchor used to navigate straight to v1 before the user could pick v1 vs v0. Intercept that first tap to open the menu; second tap (or selecting an item) navigates. Desktop hover behavior is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pain point
When I was on my phone tapping around the docs / examples site, the Examples and Documentation items in the topbar each have a dropdown (v1 / v0). On desktop it shows up on hover, which is great — but on touch the hover never fires, so my first tap just navigated me straight to v1. I never even got the chance to pick v0.

Fix
Made the first tap on those dropdown triggers open the menu instead of navigating, but only on touch / no-hover devices (
matchMedia('(hover: none)')). The second tap (or tapping a menu item) navigates as normal. Outside-tap and Escape close it. Desktop hover is untouched.Two tiny changes:
globals.css— added.nav-dd.opento the existing:hover/:focus-withinrules so a JS-toggled class can reveal the menu.Topbar.astro— small script inside the existing<script>block that wires up the tap intercept on(hover: none)devices.How I verified
Ran the dev server locally and drove it with Playwright in two contexts:
hasTouch: true, viewport 1280×800 so desktop nav is rendered): first tap opens the dropdown without navigating,.openclass is applied, menu becomes visible; outside tap closes; tapping the v0 entry navigates correctly. Same flow checked for the Documentation dropdown. 9/9 assertions pass./docs/examples— no regression.