From ecb653ca12e8490776fa6e7d8979c8ac22ce2777 Mon Sep 17 00:00:00 2001 From: Maksim Zakharov <251575087+bit-byte0@users.noreply.github.com> Date: Fri, 10 Jul 2026 14:20:21 +0400 Subject: [PATCH] feat(pivotGrid): add context menu keyboard trigger detection --- .../cell_context_menu.test.ts | 35 +++++++++++++++++++ .../keyboard_navigation/cell_context_menu.ts | 8 +++++ 2 files changed, 43 insertions(+) create mode 100644 packages/devextreme/js/__internal/grids/pivot_grid/keyboard_navigation/cell_context_menu.test.ts create mode 100644 packages/devextreme/js/__internal/grids/pivot_grid/keyboard_navigation/cell_context_menu.ts diff --git a/packages/devextreme/js/__internal/grids/pivot_grid/keyboard_navigation/cell_context_menu.test.ts b/packages/devextreme/js/__internal/grids/pivot_grid/keyboard_navigation/cell_context_menu.test.ts new file mode 100644 index 000000000000..2656e4b20e49 --- /dev/null +++ b/packages/devextreme/js/__internal/grids/pivot_grid/keyboard_navigation/cell_context_menu.test.ts @@ -0,0 +1,35 @@ +import { + describe, + expect, + it, +} from '@jest/globals'; + +import { isContextMenuKeyEvent } from './cell_context_menu'; + +describe('isContextMenuKeyEvent', () => { + it('should detect the ContextMenu key', () => { + expect(isContextMenuKeyEvent({ key: 'ContextMenu', shiftKey: false })).toBe(true); + }); + + it('should detect the ContextMenu key regardless of the Shift state', () => { + expect(isContextMenuKeyEvent({ key: 'ContextMenu', shiftKey: true })).toBe(true); + }); + + it('should detect Shift+F10', () => { + expect(isContextMenuKeyEvent({ key: 'F10', shiftKey: true })).toBe(true); + }); + + it('should ignore F10 without Shift', () => { + expect(isContextMenuKeyEvent({ key: 'F10', shiftKey: false })).toBe(false); + }); + + it('should ignore Shift without F10', () => { + expect(isContextMenuKeyEvent({ key: 'Shift', shiftKey: true })).toBe(false); + }); + + it('should ignore unrelated keys', () => { + expect(isContextMenuKeyEvent({ key: 'Enter', shiftKey: false })).toBe(false); + expect(isContextMenuKeyEvent({ key: 'ArrowDown', shiftKey: false })).toBe(false); + expect(isContextMenuKeyEvent({ key: ' ', shiftKey: false })).toBe(false); + }); +}); diff --git a/packages/devextreme/js/__internal/grids/pivot_grid/keyboard_navigation/cell_context_menu.ts b/packages/devextreme/js/__internal/grids/pivot_grid/keyboard_navigation/cell_context_menu.ts new file mode 100644 index 000000000000..0561763ff34c --- /dev/null +++ b/packages/devextreme/js/__internal/grids/pivot_grid/keyboard_navigation/cell_context_menu.ts @@ -0,0 +1,8 @@ +const F10_KEY = 'F10'; +const CONTEXT_MENU_KEY = 'ContextMenu'; + +export function isContextMenuKeyEvent( + event: Pick, +): boolean { + return event.key === CONTEXT_MENU_KEY || (event.shiftKey && event.key === F10_KEY); +}