Repository navigation
Twenty Twelve: Fix sub-menu access on touch devices - #14983
Sukhendu2002 wants to merge 1 commit into
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
The touch handler in Twenty Twelve's
navigation.jsis delegated frombodysince [30746] (https://core.trac.wordpress.org/ticket/24767). That change moved it off the links so it would also match.page_item_has_children. Since Chrome 56 and iOS Safari 11.3,touchstartlisteners onwindow,documentandbodyare passive by default, so the handler'se.preventDefault()is ignored. Chrome logs:As a result, on touch devices the first tap on a parent menu item follows its link, and the sub-menu can never be reached.
Changes
touchstarthandler from.main-navigationinstead ofbody. This keeps the selectors from [30746]. A listener on a non-document-level element is not passive, sopreventDefault()takes effect again.(min-width: 600px)matches. That is the breakpoint wherestyle.csshides sub-menus behind hover. Below it, the toggle menu already shows sub-menus inline, so a parent link should still work on the first tap.twentytwelve-navigationscript version to bust caches.Twenty Thirteen's handler binds directly to the links and still works, so no change is needed there. Twenty Fourteen is tracked separately in https://core.trac.wordpress.org/ticket/30575.
Testing instructions
.page_item_has_childrenfallback), and repeat steps 4–6.Trac ticket: https://core.trac.wordpress.org/ticket/30686
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Investigating the root cause, initial patch drafting.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.