Skip to content

feat: add useSortable hook - #930

Open
akashvekariya wants to merge 3 commits into
cosscom:mainfrom
akashvekariya:feat/use-sortable
Open

akashvekariya wants to merge 3 commits into
cosscom:mainfrom
akashvekariya:feat/use-sortable

Conversation

@akashvekariya

@akashvekariya akashvekariya commented Nov 23, 2026 •

Copy link
Copy Markdown

Summary

Adds useSortable, a headless hook for reordering items by drag or keyboard, within a list and between lists (for example the columns of a board). It has no new dependency and no visuals of its own: you spread its props on your own elements, so it works with Card, Badge and the rest.

Discussed in #929.

  • Mouse, pen and touch (press and hold, so swipes still scroll), with a drag overlay and auto-scroll near edges
  • Full keyboard moves and screen reader announcements
  • canMove to refuse a move (for example a full column), with a data-drop-refused attribute for styling
  • dragFrom: "item", "handle" or "both"
  • Vertical, horizontal and grid layouts, nested lists, and lists that only render visible rows
  • Typed by your state shape, so a useState setter works as onValueChange

What is included

  • registry/default/hooks/use-sortable.ts and its entry in registry-hooks.ts
  • Docs page content/docs/hooks/use-sortable.mdx with list and board demos (components/sortable-demo.tsx), plus hooks/meta.json and llms.txt
  • Unit tests for the move and keyboard helpers (tests/hooks/use-sortable.test.ts)
  • Generated registry files and the synced packages/ui copy

Testing

  • format:all, registry:validate-deps, registry:build, ui:sync, lint, typecheck and test pass locally
  • Tried by hand on the docs site: mouse drags, keyboard moves, refused moves, nested lists, grids, a 300-row list that only renders visible rows, and the layout on iOS Safari
  • Right-to-left keyboard handling is covered by the unit tests

Notes

  • Five kanban particles built on the hook are ready as a separate follow-up, only if you want them.
  • Happy to rename, trim or change the API to fit the library.

Generated with Claude Code


Start Proof
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

akashvekariya and others added 3 commits November 23, 2026 14:40
Adds a headless hook for reordering items by drag or keyboard, within a
list and between lists, such as the columns of a board.

- Mouse, pen and touch (press and hold) drags with a drag overlay and
  edge auto-scroll
- Full keyboard moves with screen reader announcements
- canMove to refuse moves, with a data-drop-refused signal
- Optional drag handles, controlled or uncontrolled value
- Docs page with list and board demos, and unit tests for the move and
  keyboard helpers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- dragFrom ("item" | "handle" | "both") replaces handle and dragFromItem
- orientation "grid" for wrapping layouts, with row moves by keyboard
- A sortable list inside a sortable item no longer starts both drags
- Drop index stays right when only visible rows are rendered
- Value is typed by your state shape, so useState setters work as
  onValueChange
- Docs for grids, nested lists, containers anywhere and long lists

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 23, 2026

Copy link
Copy Markdown

@akashvekariya is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
vercel Bot temporarily deployed to Preview – coss-com-origin November 23, 2026 11:13 Inactive
@vercel

vercel Bot commented Nov 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
coss-com-origin Skipped Skipped Nov 23, 2026 11:13am UTC

Request Review

@akashvekariya
akashvekariya marked this pull request as ready for review November 23, 2026 11:16

This branch was previously deployed

1 inactive deployment
Preview – coss-com-origin — 9e6e0a3a Deployed Nov 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant