Skip to content

feat(folders): drag-and-drop reorder for all folders#645

Open
shukiv wants to merge 1 commit into
bulwarkmail:mainfrom
shukiv:feat/reorder-folders
Open

feat(folders): drag-and-drop reorder for all folders#645
shukiv wants to merge 1 commit into
bulwarkmail:mainfrom
shukiv:feat/reorder-folders

Conversation

@shukiv

@shukiv shukiv commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

What

Adds drag-and-drop reordering of folders in Settings → Folders ("Your Folders"). Each row gets a drag handle; dropping persists the new order via JMAP Mailbox/set { sortOrder }, and the sidebar reflects it immediately.

Reorders all folders (standard roles included), within their sibling group — it reorders, it does not reparent (dropping onto another parent's folder is ignored).

How

  • lib/utils.ts (buildMailboxTree / sortNodes): promote sortOrder to the primary sort key. Untouched folders keep sortOrder: 0, so the default arrangement (role priority → year → name) is unchanged until the user drags something. Sidebar + settings share this builder, so both respect the order.
  • stores/email-store.ts: new reorderMailboxes(client, orderedIds) — assigns 1-based sortOrder to a sibling group, optimistic local update, persists each via updateMailbox, re-syncs on failure. Handles shared-account (viewingAccountId) views.
  • components/settings/folder-settings.tsx: @dnd-kit DnD context; a SortableContext per sibling group; a SortableFolderRow handle wrapper. Pointer sensor with a 5px activation distance so the row's existing buttons still work; keyboard sensor for a11y.
  • New deps: @dnd-kit/core, @dnd-kit/sortable, @dnd-kit/utilities.
  • i18n: settings.folders.reorder / reorder_error (en + he).

Testing

  • Drag a folder within its level → order persists, sidebar updates, survives reload
  • Default (nothing dragged) order unchanged
  • Row buttons (rename/delete/create-subfolder/icon) still click without starting a drag
  • Keyboard: focus handle → space + arrows reorders
  • Drop onto a different parent's folder → ignored (no reparent)
  • tsc clean; lint clean (no new warnings)

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