Skip to content

feat: drag-to-reorder snippets in Settings#56

Merged
StanK23 merged 5 commits intomainfrom
feature/snippet-reorder
Feb 28, 2026
Merged

feat: drag-to-reorder snippets in Settings#56
StanK23 merged 5 commits intomainfrom
feature/snippet-reorder

Conversation

@StanK23
Copy link
Owner

@StanK23 StanK23 commented Feb 28, 2026

Summary

  • Add reorderSnippets(fromIndex, toIndex) store action using splice-remove + insert pattern
  • Add HTML5 drag-and-drop to snippet rows in SettingsPanel with drag handle, opacity feedback, and accent highlight on drop target
  • Follows same DnD pattern as workspace tab reorder in TabBar

Test plan

  • Open Settings > Commands with 3+ snippets
  • Drag a snippet by the grip handle — verify opacity drops on source, accent highlight on target
  • Drop on a different position — verify order persists after closing/reopening Settings
  • Verify editing and deleting still work after reorder
  • Verify snippet dropdown in pane header reflects new order

🤖 Generated with Claude Code

Add reorderSnippets store action and HTML5 drag-and-drop to snippet rows
with drag handle, opacity feedback, and accent highlight on drop target.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@StanK23
Copy link
Owner Author

StanK23 commented Feb 28, 2026

Automated Review — Findings

Summary: 3 files reviewed, 8 agents ran (code quality, security, simplification, DRY/reuse, comments, types, frontend UI, TypeScript)

Must Fix (4 items)

  • store/index.ts:922 — [6 agents] Add console.warn for out-of-range indices (inconsistent with reorderWorkspaceTabs)
  • SettingsPanel.tsx:224 — [frontend-ui] Drag handle not keyboard-accessible (needs role="button", tabIndex, key handlers)
  • SettingsPanel.tsx:174 — [frontend-ui] Missing ARIA aria-roledescription on draggable rows
  • SettingsPanel.tsx:174 — [frontend-ui] No aria-live announcement after reorder

Suggestions (8 items)

  • store + SettingsPanel + TabBar — [5 agents] Extract shared useDragReorder hook + reorderArray utility (follow-up)
  • store/index.test.ts — [code-reviewer, dry-reuse] Add unit tests for reorderSnippets
  • SettingsPanel.tsx:143 — [3 agents] Add e.dataTransfer.setData() call (Firefox compat)
  • SettingsPanel.tsx:177 — [frontend-ui] Hide drag handle during edit mode
  • SettingsPanel.tsx:166 — [frontend-ui] Hide drag handle when single snippet
  • store/index.ts:926 — [code-simplifier, typescript-pro] Remove unreachable if (!moved) return guard
  • SettingsPanel.tsx:182 — [code-simplifier] Extract drag classes into local variable
  • SettingsPanel.tsx:143 — [typescript-pro] Align handleDragStart signature with TabBar

Nitpicks (3 items)

  • SettingsPanel.tsx:228 — Braille char may not render on all platforms
  • SettingsPanel.tsx:182 — className concat could use clsx
  • store/index.ts:254 — JSDoc could clarify post-removal indexing

Review ran: code-reviewer, security-auditor, code-simplifier, dry-reuse, comment-analyzer, type-design-analyzer, frontend-ui, typescript-pro

StanK23 and others added 4 commits March 1, 2026 00:31
Match the reorderWorkspaceTabs pattern for consistent error observability.
Also remove unreachable dead-code guard after splice.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Drag handle is now a <button> with tabIndex for keyboard access
- Alt+ArrowUp/Down moves snippets via keyboard
- aria-roledescription="reorderable snippet" on draggable rows
- aria-live region announces position changes to screen readers
- aria-label includes position info (item N of M)
- Add e.dataTransfer.setData() for Firefox DnD compat
- Hide drag handle during edit mode and when single snippet
- Extract drag class logic into named variables for readability

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Mirror the existing reorderWorkspaceTabs test suite: forward move,
backward move, same-index no-op, out-of-range no-op with warn, and
persistence verification.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@StanK23
Copy link
Owner Author

StanK23 commented Feb 28, 2026

Review Fixes Applied

Fixed:

  • store/index.ts:922 — Added console.warn on out-of-range indices + removed unreachable dead-code guard
  • SettingsPanel.tsx:251 — Drag handle is now a <button> with tabIndex for keyboard focus
  • SettingsPanel.tsx:255 — Added onKeyDown with Alt+ArrowUp/Down for keyboard reorder
  • SettingsPanel.tsx:240 — Added aria-roledescription="reorderable snippet" on rows
  • SettingsPanel.tsx:295 — Added aria-live="polite" region announcing position changes
  • SettingsPanel.tsx:253 — aria-label includes position info ("item N of M, use Alt+Arrow keys")
  • SettingsPanel.tsx:145 — Added e.dataTransfer.setData('text/plain', '') for Firefox compat
  • SettingsPanel.tsx:250 — Drag handle hidden during edit mode (shows empty spacer)
  • SettingsPanel.tsx:250 — Drag handle hidden when only one snippet
  • SettingsPanel.tsx:243-245 — Extracted drag classes into named variables for readability
  • index.test.ts — Added 5 unit tests for reorderSnippets (forward, backward, no-op, OOB, persist)

Skipped (with reason):

  • Extract shared useDragReorder hook — follow-up task, only 2 call sites currently
  • Extract shared reorderArray utility — follow-up task, same rationale
  • Align handleDragStart signature with TabBar — moot without shared hook extraction
  • Braille char portability — U+283F has excellent cross-platform font support
  • clsx for className concat — project doesn't use clsx, named variables already address readability
  • JSDoc wording — matches reorderWorkspaceTabs exactly, changing both is out of scope

All changes in latest push

@StanK23 StanK23 merged commit d6ab009 into main Feb 28, 2026
1 check failed
@StanK23 StanK23 deleted the feature/snippet-reorder branch February 28, 2026 17:42
StanK23 added a commit that referenced this pull request Feb 28, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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