Skip to content

feat(sidebar): Drag to reorder nav items in customize dialog#3670

Merged
charlesvien merged 3 commits into
mainfrom
feat/sidebar-nav-reorder
Jul 22, 2026
Merged

feat(sidebar): Drag to reorder nav items in customize dialog#3670
charlesvien merged 3 commits into
mainfrom
feat/sidebar-nav-reorder

Conversation

@charlesvien

@charlesvien charlesvien commented Jul 22, 2026

Copy link
Copy Markdown
Member

Problem

The customize sidebar dialog lets you show or hide nav items, but their order is fixed.

Changes

Adds a drag handle to each row in the customize dialog. Dragging reorders the list live, persists the order and the sidebar nav renders in that order (hidden items keep it under More too). A canceled drag restores the order from dragstart. Reorders fire a new "Sidebar reordered" event. Stored order is sanitized on rehydrate and newly shipped items fall back to their default position.

How did you test this?

Unit tests for the order helpers, store rehydration and the dialog drag handlers (116 sidebar tests pass), plus typecheck and Biome. Not exercised in the running app.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

charlesvien commented Jul 22, 2026

Copy link
Copy Markdown
Member Author

@charlesvien charlesvien changed the title add drag to reorder nav items in customize dialog feat(sidebar): Drag to reorder nav items in customize dialog Jul 22, 2026
@charlesvien
charlesvien marked this pull request as ready for review July 22, 2026 02:55
@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 4265c4c.

Base automatically changed from feat/sidebar-more-customize to main July 22, 2026 03:02
@greptile-apps

greptile-apps Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix the following 3 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 3
packages/ui/src/features/sidebar/constants.ts:115-116
**Repeated Hover Reverses The Move**

`dragover` can fire repeatedly while the pointer remains over one target, but this move is not idempotent. Moving adjacent `A` onto `B` first produces `[B, A]`; the next event with the same source and target restores `[A, B]`, so rows can oscillate and the persisted drop order depends on the number of pointer events.

### Issue 2 of 3
packages/ui/src/features/sidebar/constants.ts:97-102
**New Items Lose Default Position**

Every ID missing from a stored order receives a position after all stored IDs. Once an existing user has dragged and persisted the current full list, a newly shipped item inserted in the middle of `CUSTOMIZABLE_NAV_ITEMS` is therefore rendered at the end instead of its default position, giving existing users the wrong navigation order.

### Issue 3 of 3
packages/ui/src/features/sidebar/components/CustomizeSidebarDialog.tsx:83-90
**Unmount Leaves Intermediate Order Persisted**

Each hover immediately writes an intermediate order to the persisted store, while restoration exists only in `handleDragEnd`. If the dialog closes or its provider unmounts during an active drag before that callback runs, the last hover position remains saved even though the drag was never dropped.

Reviews (1): Last reviewed commit: "add drag to reorder nav items in customi..." | Re-trigger Greptile

@trunk-io

trunk-io Bot commented Jul 22, 2026

Copy link
Copy Markdown

😎 This pull request was merged.

Comment thread packages/ui/src/features/sidebar/constants.ts
Comment thread packages/ui/src/features/sidebar/constants.ts Outdated
@charlesvien
charlesvien force-pushed the feat/sidebar-nav-reorder branch from f5fdc20 to 418c147 Compare July 22, 2026 03:07
@charlesvien charlesvien added the Stamphog This will request an autostamp by stamphog on small changes label Jul 22, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contained UI/store feature (drag-to-reorder sidebar items), no risky territory touched; the three prior Greptile findings (oscillating dragover, new items losing position, intermediate order persisting on unmount) are each fixed in the current diff with matching new tests, and the author has strong familiarity with this code.

  • Author wrote 100% of the modified lines and has 23 merged PRs in these paths (familiarity STRONG).
  • 👍 on the PR from greptile-apps[bot].
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 270L, 5F substantive, 569L/9F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1d-complex (569L, 9F, single-area, feat)
stamphog 2.0.0b3 .stamphog/policy.yml @ f3e4b42 · reviewed head 4265c4c

@charlesvien
charlesvien enabled auto-merge (squash) July 22, 2026 03:18
@charlesvien
charlesvien disabled auto-merge July 22, 2026 03:35
@charlesvien
charlesvien merged commit cf8d999 into main Jul 22, 2026
40 checks passed
@charlesvien
charlesvien deleted the feat/sidebar-nav-reorder branch July 22, 2026 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stamphog This will request an autostamp by stamphog on small changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant