固化键盘菜单键不被右键手势拦截的口径
Project CI / AI game creator shell Rust crates (pull_request) Successful in 2m58s
Project CI / Backend tests (pull_request) Failing after 12s
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 3m57s
Project CI / Frontend tests (pull_request) Successful in 3m6s
Project CI / Repository checks (pull_request) Failing after 11s
Project CI / AI game creator shell web tests (pull_request) Successful in 1m41s
Project CI / Native shell tests (pull_request) Successful in 6m13s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Successful in 9m32s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Successful in 10m50s

- 实测 Chromium 151 下键盘菜单键触发的是 button: -1,previewRightPanGesture 注释写明只认按钮 2 的原因
- previewRightPanGesture.test.ts 增加 button: -1 不拦截的判据用例
- previewRightPanDrag.test.tsx 增加键盘菜单键仍走原有节点菜单路径的集成用例
- decision-log 条目补上该实测结论与新增用例的验证口径

验证:npx vitest run previewRightPanDrag.test.tsx previewRightPanGesture.test.ts(13 passed)
This commit is contained in:
2026-09-22 15:35:51 +08:00
parent 0ab04d0f64
commit d5e06de33e
4 changed files with 24 additions and 2 deletions
@@ -79,6 +79,7 @@ export function resolvePreviewRightPanRelease({
* 平台差异:Windows / Linux 的 Chromium 与 Firefox 在**按下**时触发 contextmenu,
* macOS 在指针抬起之后触发;而原生菜单一旦弹出,页面之后收不到 pointermove / pointerup,
* 所以必须按下时就拦截,并把拦截窗口保留到下一次指针按下之前。
* 键盘菜单键不在此列:Chromium 实测上报 `button: -1`,只认 2 正好把它留给原有菜单路径。
*/
export function shouldInterceptRightContextMenu({
button,
@@ -350,6 +350,21 @@ describe('PreviewWorkspace right-button pan', () => {
expect(screen.getByRole('menu')).toBeTruthy();
});
it('leaves the keyboard menu key to the existing node menu path', () => {
const { canvas, child } = renderPreview();
dispatchPointer(child, 'pointerdown', {
button: 2,
clientX: 100,
clientY: 100,
pointerId: 13,
});
// 键盘菜单键在 Chromium 上报 button: -1,不能被右键手势的拦截窗口吃掉。
expect(fireEvent.contextMenu(child, { button: -1 })).toBe(false);
expect(canvas.selectNode).toHaveBeenCalledWith('child');
expect(screen.getByRole('menu')).toBeTruthy();
});
it('keeps middle-button panning and its shared grabbing cursor', () => {
const { container, preview } = renderPreview();
const before = worldTranslate(container);
@@ -96,5 +96,11 @@ describe('preview right-button pan gesture', () => {
withinRightPressSequence: true,
}),
).toBe(false);
expect(
shouldInterceptRightContextMenu({
button: -1,
withinRightPressSequence: true,
}),
).toBe(false);
});
});