AsterUIDocsv1.0.2

Docs / Guides

Confirm a decision in context

Archive workflow example

Use a dialog when a user needs to inspect details before acting. Give the action a visible name, describe its effect, and provide a way back. Select Review archive, keep editing or archive the draft, and try restoring it. Escape cancels the open confirmation.

Install the dialog, button and badge with npx @fierst/ui@1.0.2 add dialog button badge. Save the JSX next to the installed ui directory and import the example in your Aster app.

Keep the open state in one place

In this recipe the trigger sets an action flag. The next time the parent advances, it delegates to confirmDialog. The helper owns the open dialog until the user chooses Archive draft or Keep editing. The parent records the returned boolean, resets its action flag and displays the updated badge. For an independently controlled dialog, inspect the getter/setter binding in the Dialog example.

Return a decision to a workflow

For a sequential task, delegate to confirmDialog from the parent generator. Its boolean result lets the caller apply the change only after confirmation. Use a delegated step inside the generator body. A DOM click callback can request that step on the next render.

tsx
const accepted = yield* confirmDialog({
  title: 'Archive this draft?',
  confirmLabel: 'Archive',
  cancelLabel: 'Keep editing'
});
if (accepted) archiveDraft();

For an action that needs an explicit confirmation phrase, use the registry’s AlertDialog. Test acceptance, cancellation and focus when the surrounding view changes. Try AlertDialog.