gm-datagrid 0.1.16 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -400,9 +400,10 @@ async function saveRow(newRow, oldRow) {
400
400
  | `Enter` | Save and move to the next row |
401
401
  | `Tab` / `Shift+Tab` | Save and move right / left |
402
402
  | `Escape` | Discard and exit edit mode |
403
- | Arrow keys | Move focused cell (outside edit mode) |
403
+ | Arrow keys | Move focused cell (view mode only) |
404
+ | `Ctrl+Arrow` / `Meta+Arrow` | Passed through to the browser — never hijacked |
404
405
 
405
- If `processRowUpdate` throws, the cell reverts automatically to its original value.
406
+ > **Focus-scoped keyboard handling** — all grid keyboard shortcuts are active **only when focus is inside the grid**. Arrow keys, `Shift+Arrow`, `Ctrl+Arrow`, and clipboard shortcuts (`Ctrl+C` / `Ctrl+V`) in other inputs or text areas on the same page are never intercepted by the grid.
406
407
 
407
408
  ---
408
409
 
@@ -1,3 +1,4 @@
1
+ import { default as React } from 'react';
1
2
  import { CellRange, ColumnDef, Row } from '../types';
2
3
  interface UseClipboardProps {
3
4
  range: CellRange | null;
@@ -6,7 +7,9 @@ interface UseClipboardProps {
6
7
  engine: any;
7
8
  engineReady: boolean;
8
9
  onPasted: () => void;
10
+ /** Grid root element — clipboard shortcuts only fire when focus is inside. */
11
+ gridRootRef: React.RefObject<HTMLDivElement | null>;
9
12
  }
10
13
  /** Serializes selected range to TSV for Ctrl+C; parses TSV from Ctrl+V. */
11
- export declare function useClipboard({ range, visibleRows, columns, engine, engineReady, onPasted, }: UseClipboardProps): void;
14
+ export declare function useClipboard({ range, visibleRows, columns, engine, engineReady, onPasted, gridRootRef, }: UseClipboardProps): void;
12
15
  export {};
@@ -7,7 +7,9 @@ interface UseKeyboardNavProps {
7
7
  stopEditing: (save: boolean) => Promise<void>;
8
8
  totalRows: number;
9
9
  columns: ColumnDef[];
10
- containerRef: React.RefObject<HTMLDivElement>;
10
+ /** Root element of the grid — the listener is scoped to this element so it
11
+ * never intercepts keystrokes when focus is outside the grid. */
12
+ gridRootRef: React.RefObject<HTMLDivElement | null>;
11
13
  }
12
14
  /**
13
15
  * Keyboard navigation contract (Excel-like):
@@ -18,6 +20,14 @@ interface UseKeyboardNavProps {
18
20
  * - Tab: save, move focus one column right
19
21
  * - Shift+Tab: save, move focus one column left
20
22
  * - Escape: discard, exit edit mode
23
+ *
24
+ * IMPORTANT: The listener attaches to the grid root element, NOT document.
25
+ * This means:
26
+ * - Arrow / Tab / Enter keys only fire grid navigation when focus is inside
27
+ * the grid — they never steal keystrokes from inputs, text selections, or
28
+ * other page widgets outside the grid.
29
+ * - Ctrl+Arrow, Shift+Arrow, and any browser-native text-selection shortcuts
30
+ * are passed through untouched when the event originates outside the grid.
21
31
  */
22
- export declare function useKeyboardNav({ focusedCell, setFocusedCell, editingCell, startEditing, stopEditing, totalRows, columns, }: UseKeyboardNavProps): void;
32
+ export declare function useKeyboardNav({ focusedCell, setFocusedCell, editingCell, startEditing, stopEditing, totalRows, columns, gridRootRef, }: UseKeyboardNavProps): void;
23
33
  export {};