#080
Async onconfirm
A destructive alert dialog whose async confirm handler waits 1.5 seconds before an Item removed note appears.
Hand this to your AI. It names the exact library parts, timings and accessibility promises of this demo.
Build the "Async onconfirm" pattern (@codeatlasdev/ui demo #080, feedback/alert-dialog) in my app.
Call get_demo({ ids: ["#080"] }) first and keep its structure. It needs @codeatlasdev/[email protected].
Use: Confirming a delete that calls the server, where the dialog waits for the request before closing.
Keep these library parts, with the props and tokens the demo uses:
- AlertDialog, Button from "@codeatlasdev/ui"
Behaviour to keep:
- `<AlertDialog` with `bind:open`, `title="Remove item?"` and `confirmLabel="Remove"`
- `destructive` flag set on the dialog
- `onconfirm={removeItem}` is an async function that awaits `wait(1500)` then sets `done = true`
- Trigger is `<Button variant="destructive"` labelled Remove item (1.5s)
- Result note uses `aria-live="polite"` and shows when `{#if done}`
Reduced motion: the demo handles it; keep that branch.
Keyboard: operable; keep the focus order and key handling.
Change only the copy and the data. Use the theme tokens (--ca-*), never raw colours. Library parts
- AlertDialog
@codeatlasdev/ui - Button
@codeatlasdev/ui
How it is built
- `<AlertDialog` with `bind:open`, `title="Remove item?"` and `confirmLabel="Remove"`
- `destructive` flag set on the dialog
- `onconfirm={removeItem}` is an async function that awaits `wait(1500)` then sets `done = true`
- Trigger is `<Button variant="destructive"` labelled Remove item (1.5s)
- Result note uses `aria-live="polite"` and shows when `{#if done}`
Related
Loading source.