move-column
Moves a column to a new position in the board's column order. Handles column reordering from the UI and from code. Only the column configuration changes. Cards stay in their columns, and the editor stays as it is.
Usage
type MoveColumnPayload = {
id: ColumnID;
before?: ColumnID | null;
};
| Field | Type | Description |
|---|---|---|
id | string | number | The column to move |
before | string | number | null | The column to place it in front of. Omitted, null, or an unknown id appends it to the end |
The action is a no-op when id matches no column, when before is the column itself, or when the move leaves the column at its current index. A no-op keeps the undo/redo history. A move that changes the order resets both history stacks.
Trigger
// place "done" in front of "doing"
api.exec("move-column", { id: "done", before: "doing" });
// move "backlog" to the end
api.exec("move-column", { id: "backlog" });
Observe
api.on("move-column", ev => {
console.log("Column moved:", ev.id, "before", ev.before);
});
Intercept
api.intercept("move-column", ev => {
// keep the "backlog" column in place
if (ev.id === "backlog") return false;
});
Component handler
Kanban forwards the action to the onMoveColumn prop.
<Kanban
cards={cards}
columns={columns}
onMoveColumn={(ev) => console.log("Column moved:", ev.id)}
/>
Related
- Columns guide - column setup, layout, and runtime updates
- columns - column definitions in board order
- update-column - patch a column's configuration