Task quick add

The last row of a task list. It reads “Add a task” until it's opened with a click or N; then you write the whole task in the title, as you'd say it. The words that name a date, a person or a priority are underlined as you type and fill their slots on the right, and Tab steps through the slots to check or change each. Every detail is optional: Enter adds, Esc cancels and puts focus back on the row, and after adding the field stays open and empty for the next one. A task just added never gets the highlight.

BetaReady to use. Its API can still change in a minor release; the changelog says when.

LEAP CRMBuilt for the CRM from the core library. It knows about the CRM's own records, so it isn't a general building block.

import { parseTaskSentence, TaskQuickAdd } from "@leap-crm/design-system";

Playground

Change a prop and the component follows. Its code is under Props.

Props

mode
defaultPriority
shortcut

Best practices

When to use it, and the rules that apply in particular places.

GuidancePractice
DoPass it as TaskList's addRow, so it is the last row of the open tasks.
DoPass people, so a name in the sentence, like “for Mia”, fills the assignee slot.
DoSet shortcut={false} on every add row but one when a page holds more than one. It is on by default, and N should open one row.
DoSet defaultOpen only on a page that's only for adding tasks. Elsewhere it reads “Add a task” until it's opened.
Don'tAdd separate date, assignee or priority fields beside it. The sentence fills those slots, and Tab steps through them to check or change each.

Props

PropTypeDefaultDescription
mode"steps" | "tokens""steps"Steps: write the whole task in the title, like "Order strata report by Friday for Mia, high priority"; the date, the person and the priority it names fill their slots as you type, and Tab steps through them to check or change each. Tokens: @, ! and day names turn into tokens as you type.
peopleunknown[]Who a task can be assigned to. People on this matter come first.
onAdd *(task: TaskDraft) => void—Runs with the new task when it's added. The row then clears and stays open for the next one.
defaultPriority"low" | "medium" | "high" | "urgent" | "critical""medium"The priority a task gets when none is chosen.
shortcutbooleantruePressing N anywhere outside a text field opens the row.
todaystring—Today's ISO date. The page's today by default.
defaultOpenbooleanfalseStarts open, for a page that's only for adding.
classNamestring—Classes added to the root element, merged with its own. Tokens only.

Code

What the playground shows, ready to copy.

import { TaskQuickAdd } from "@leap-crm/design-system";

<TaskQuickAdd onAdd={addTask} />

Keyboard

The keys it answers to. Tab moves between components, arrows move within them.

KeysWhat they do
NOpens the add row, when its shortcut is on and focus isn't in a text field.
EnterAdds the task.
ArrowDownArrowUpWhile a list of suggestions is open, move through it.
EnterTabWhile a list of suggestions is open, accept the highlighted one.
BackspaceIn an empty field, removes the last token.
EscapeCloses an open picker first, then cancels the draft and puts focus back on the row.