Skip to content

feat(context-menu): verify long-press contextmenu on touch and codify priority order #306

@OysteinAmundsen

Description

@OysteinAmundsen

Sub-issue of #302 — Category E.

Goal

Verify that ContextMenuPlugin already works on touch via native long-press → contextmenu synthesis, fix any preventDefault that suppresses it, and codify the long-press priority order across plugins.

Background

Modern browsers fire contextmenu from:

  • Right-click (mouse)
  • Two-finger tap (macOS / Windows / iPadOS trackpad)
  • Long-press (iOS Safari, Android Chrome, Windows touchscreen) — provided the page doesn't preventDefault() touchstart or pointerdown on the target

libs/grid/src/lib/plugins/context-menu/ContextMenuPlugin.ts:523 already listens for contextmenu, so trackpad two-finger tap and right-click work today. The unknown is whether finger long-press fires contextmenu on grid cells, or whether something in cell event delegation is suppressing it.

This sub-issue is mostly verification + documentation. Likely zero or near-zero net code.

In scope

Verification

  • Add Playwright touch-emulation tests that perform a 600 ms long-press on:
  • If long-press does NOT fire contextmenu on cells today, locate the offending preventDefault() (likely in event-delegation.ts or RowDragDropPlugin) and narrow it.

Long-press priority order — codify and document

Per #302's resolution policy:

Target Long-press action Condition
Header Open header menu (#270) Always (when #270 registered)
Row Enter row selection mode When SelectionPlugin mode includes 'row'
Row Open ContextMenuPlugin Otherwise (or via "More…" inside selection-mode toolbar)
Cell Enter cell range-paint mode When SelectionPlugin mode includes 'cell' or 'range'
Cell Open ContextMenuPlugin Otherwise (or via "More…" inside selection-mode toolbar)

Document this priority order in:

  • ContextMenuPlugin.ts JSDoc (class-level)
  • apps/docs/src/content/docs/grid/guides/touch-input.mdx (cross-cutting sub-issue owns this file)
  • ContextMenuPlugin.mdx plugin docs page

ContextMenuPlugin "More…" item in selection-mode toolbar

When both ContextMenuPlugin and SelectionPlugin are registered AND selection-mode is active (Category C), SelectionPlugin's toolbar surfaces a "More…" button that opens ContextMenuPlugin's menu — this preserves right-click parity even when long-press is consumed by selection mode.

This wiring is implemented in Category C's sub-issue; this sub-issue only documents the contract.

Out of scope

  • Implementing a long-press polyfill — modern browsers handle it natively.
  • Custom long-press timing per device class (single 400 ms threshold for selection mode entry; native browser handles contextmenu timing, typically ~500 ms).
  • Selection-mode toolbar implementation — Category C.

Acceptance criteria

  • Playwright touch-emulation test confirms long-press fires contextmenu on cells when ContextMenuPlugin is registered alone (no SelectionPlugin).
  • Same test confirms long-press fires contextmenu on rows when applicable.
  • If a preventDefault() is currently suppressing native long-press → fix narrowed; before/after test demonstrates the regression-fix.
  • ContextMenuPlugin.ts class-level JSDoc documents the long-press priority order.
  • apps/docs/src/content/docs/grid/plugins/context-menu.mdx (or equivalent) updated with a "Touch input" section linking to the touch guide.
  • No regression on existing right-click and Shift+F10 keyboard handling (context-menu.spec.ts passes).

Dependencies

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    PluginBelongs in existing plugin or creation of newenhancementNew feature or request

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions