Skip to content

fix(deck): stand down keyboard nav during an active dnd-kit keyboard drag - #67

Merged
aaronjmars merged 1 commit into
mainfrom
fix/deck-keyboard-nav-drag-guard
Jun 9, 2026
Merged

aaronjmars merged 1 commit into
mainfrom
fix/deck-keyboard-nav-drag-guard

Conversation

@aaronjmars

Copy link
Copy Markdown
Collaborator

Problem

PR #66 added window-level keyboard navigation (j/k/c///Esc) for deck columns. Its handler bails when a text field (input/textarea/select/contentEditable) is focused. But the drag-to-reorder from PR #65 uses dnd-kit's KeyboardSensor, whose drag is driven from a <button> drag handle — not a text field. So during an active keyboard drag, ArrowLeft/ArrowRight/Escape were consumed by both dnd-kit's sensor (to move/cancel the drag) and the column-nav handler (to move focus / clear focus) on the same keypress.

Fix

Track active-drag state in a draggingRef:

  • set true on DndContext onDragStart
  • cleared on onDragEnd and onDragCancel
  • the window key handler bails early while draggingRef.current is true

So during a keyboard reorder, the KeyboardSensor exclusively owns arrows/Escape until the column drops or the drag cancels. A merely-focused (not dragging) handle still allows nav, because arrows don't start a dnd-kit drag — only Space/Enter does — so there's no over-suppression.

Verification

  • tsc --noEmit: zero errors in deck-board.tsx (only the pre-existing lib/integrations/pypi.ts errors remain, untouched).
  • eslint components/deck/deck-board.tsx: clean (exit 0).
  • Ref-based, so the keydown useEffect dependency array is unchanged (no re-bind, no stale closure).

🤖 Generated with Claude Code

…drag

#66's window-level j/k/c//Esc handler bails when a text field is focused,
but a dnd-kit keyboard drag (#65) is driven from a <button> drag handle —
so during an active keyboard reorder the same ArrowLeft/ArrowRight/Escape
keys were handled by BOTH the KeyboardSensor and the column-nav handler.

Track drag state in a ref (set on onDragStart, cleared on onDragEnd /
onDragCancel) and bail the key handler while a drag is in progress, so the
KeyboardSensor exclusively owns arrows/Escape until the column drops or the
drag cancels. A merely-focused (not dragging) handle still allows nav,
since arrows don't start a drag — only Space/Enter does.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@aaronjmars
aaronjmars merged commit 183545d into main Jun 9, 2026
1 check passed
@aaronjmars
aaronjmars deleted the fix/deck-keyboard-nav-drag-guard branch June 9, 2026 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant