update-card
Patches an existing card by merging the provided partial into the stored card object. If the card ID isn't found, the action is a no-op. When history is enabled, a snapshot is pushed before the update.
Usage
type UpdateCardPayload = {
id: CardID;
card: Partial<KanbanCard>;
};
| Field | Type | Description |
|---|---|---|
id | string | number | ID of the card to update |
card | Partial<KanbanCard> | Fields to merge into the card object |
Trigger
api.exec("update-card", {
id: 1,
card: { label: "Updated title", priority: 3 },
});
Observe
api.on("update-card", ({ id, card }) => {
console.log(`Card ${id} updated:`, card);
});
Intercept
api.intercept("update-card", ({ id, card }) => {
// Prevent clearing the label
if (card.label === "") return false;
});
Component handler
<Kanban
cards={cards}
columns={columns}
onUpdateCard={({ id, card }) => {
saveToServer(id, card);
}}
/>
Related
- Editing guide - editor fields, save behavior, and validation
- Editor - the sidebar/modal component that dispatches update-card
- add-card - create a new card