Repository navigation
fix(contextmenu): touch long-press + keyboard invocation (menus-8) - #3392
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
|
Fix the conflicts for this PR |
nynexman4464
left a comment
There was a problem hiding this comment.
Tested on android phone and windows PC. Seems to work. Context menu on mobile is a bit odd, not sure that pattern is super common, but worked well enough.
FYI on windows I had a hard time activating the menu in the component doc site since there was no focus target. I changed it to a button in the playground and was able to test that way.
FWIW I don't think they put the context menu button on most win keyboards anymore, but the shift+F10 shortcut still seems recognized by the os, and worked fine here (once I had a good target to test on)
d501d64 to
2d14175
Compare
2d14175 to
34738c7
Compare
|
Rebased onto latest |
34738c7 to
e49cad6
Compare
e49cad6 to
cb225b7
Compare
Part of the accessibility & keyboard-management program (#3343). Fixes finding
menus-8.Problem
ContextMenucould only be opened by a right-clickcontextmenuevent:contextmenuevent on long-press, so context menus — including the row/cell actions that some Table plugins surface only there — were completely unreachable on iPads/phones.contextmenu(Shift+F10 / the Menu key) fires with coordinates(0, 0)in several browsers, so the menu opened pinned to the top-left viewport corner instead of near the focused element.Fix
touchstartstarts a 500ms timer; if the finger doesn't move more than 10px and doesn't lift, the menu opens at the touch point.touchmovepast the threshold (a scroll/drag) andtouchend/touchcancelclear the timer. The trigger getsWebkitTouchCallout: noneso the long-press opens our menu instead of the native iOS callout.contextmenuevent arrives withclientX/clientY === 0anddetail === 0(keyboard-initiated), the menu anchors toe.currentTarget.getBoundingClientRect()(left/bottom) instead of the event coordinates.Tests
Adds four
ContextMenu.test.tsxcases: keyboard-invoked open (positions from the trigger rect), touch long-press opens after the threshold, and long-press cancels on a >10px move. Full ContextMenu suite green (20 tests), typecheck (incl. tests) + lint clean.Note: this is additive to the ContextMenu Escape/focus-restore work in #3361 (both touch the same file; they will need a trivial rebase depending on merge order).