SortableList
A vertical list the user can rearrange: course steps, lesson blocks, form fields. Every way to move an item is equivalent, so dragging is never the only one (the same stance as KanbanBoard's "Move to…" menu): - drag the handle with a pointer; - focus the handle, Space or Enter to pick up, ↑/↓ and Home/End to move, Space or Enter to drop, Escape to put it back (tabbing away also puts it back); Alt+↑/↓ moves one step without picking up; - the row's "Move" menu, or `moveUp` / `moveDown` / `moveTo` from the render context. Moves are announced in a polite live region once they succeed. Native drag and drop needs no dependency and Radix has none to offer (docs/FRAMEWORK.md rule 3).
packages/ui/src/components/patterns/sortable-list.tsx
@marktiderman/genesis-ui/patternsimport { SortableList } from "@marktiderman/genesis-ui/patterns";react-docgen-typescript.SortableList
A vertical list the user can rearrange: course steps, lesson blocks, form fields. Every way to move an item is equivalent, so dragging is never the only one (the same stance as KanbanBoard's "Move to…" menu): - drag the handle with a pointer; - focus the handle, Space or Enter to pick up, ↑/↓ and Home/End to move, Space or Enter to drop, Escape to put it back (tabbing away also puts it back); Alt+↑/↓ moves one step without picking up; - the row's "Move" menu, or `moveUp` / `moveDown` / `moveTo` from the render context. Moves are announced in a polite live region once they succeed. Native drag and drop needs no dependency and Radix has none to offer (docs/FRAMEWORK.md rule 3).
| Prop | Type | Default | Description |
|---|---|---|---|
| getItemLabel* | (item: T) => string | — | A name for an item, for the handle's label and announcements ("Week 1"). |
| getKey* | (item: T) => string | — | A stable key per item. Required: dragging finds the item again by key. |
| items* | readonly T[] | — | |
| label* | string | — | Accessible name of the list ("Course steps"). |
| onReorder* | (from: number, to: number, move: SortableListReorder) => void | Promise<void> | — | Move the item at `from` to `to` (both from 0, `to` counted after the item is taken out). Each finished move calls this once: a keyboard pick-up that wanders and comes back calls nothing. The list shows the new order straight away and keeps showing it until the returned promise settles; by then `items` must be in the new order. A synchronous handler must update `items` in the same tick. A rejected promise puts the old order back and announces that the move failed. Other moves wait until this one settles. |
| renderItem* | (item: T, context: SortableListItemContext) => ReactNode | — | |
| className | string | — | |
| disabled | boolean | — | Turns off dragging and every kind of move. |
| itemClassName | string | — | |
| moveMenu | boolean | true | A "Move" menu on each row (up, down, to top, to bottom), on by default so touch and screen-reader users always have a way to move an item. Turn it off only when the row offers `moveUp` / `moveDown` / `moveTo` itself. |