fix(design): a right-click on selected words opens the browser's own menu (E28 S3e4b)

The row menu took every right-click, so selected text could only be copied
with Ctrl+C. On the selection (its laid-out line boxes) the event is left to
the browser; beside it the object's menu opens as before.
This commit is contained in:
2026-09-26 19:03:34 +02:00
parent 079cee4e9c
commit bd0914b7ed
3 changed files with 72 additions and 3 deletions
+6 -2
View File
@@ -7,6 +7,7 @@ import {
} from "react";
import { matchesShortcut, useKeyScope } from "../../lib/keymap";
import { pointOnSelection } from "../../lib/textSelection";
import { useAnchoredPopover } from "./anchoredPopoverHooks";
// E10 S2 — the right-click context menu's INPUT half: the gestures that open it and the row they
@@ -19,7 +20,8 @@ import { useAnchoredPopover } from "./anchoredPopoverHooks";
// cannot grow a right-click menu that looks or behaves unlike its own ⋯ menu.
//
// Three ways in, because a menu that only opens one way does not exist on the device that lacks it:
// - right-click anywhere on the row (the desktop browser, and the reason this sprint exists),
// - right-click anywhere on the row (the desktop browser, and the reason this sprint exists) —
// except on selected words, where the browser's own menu opens so they can be copied,
// - long-press (touch/pen only) — the tablet has no right button,
// - Shift+F10 / the Menu key, which is free once the row is in the tab order.
// The left button is untouched: it keeps the row's own default action (select / play).
@@ -158,9 +160,11 @@ export function useContextMenu<T>({
// menu instead of Safari's own link/image callout on top of it.
"data-context-menu-target": "",
onContextMenu: (e: React.MouseEvent<HTMLElement>) => {
e.preventDefault();
// A row inside another context-menu target (a table inside a panel) claims the event.
e.stopPropagation();
// On selected words the browser's own menu opens (Copy, Search): DESIGN "Text stays selectable".
if (pointOnSelection(e.target, e.clientX, e.clientY)) return;
e.preventDefault();
openAt(e.clientX, e.clientY, payload, e.currentTarget);
},
onPointerDown: (e: ReactPointerEvent<HTMLElement>) => {