Confirm
One question, a distinct verb, and nothing drawn by the browser.
data-confirm
Put
<.confirm_host />
in the layout once. Every element with
data-confirm
then opens the styled dialog instead of
window.confirm()
.
The click is caught before LiveView sees it and replayed on the verb.
confirm_dialog
Write the question in HEEx and open it with
SutraUI.open_confirm/1
.
Focus starts on Keep for a danger action; Escape means Keep; focus returns to the trigger.
values
arrive as event params and the inner block holds extra fields.
Retire this course?
Learners keep their certificates; nobody can start it again.
Remove Asha?
She loses access today.
Host-controlled
Pass
show
and
on_cancel
to let the LiveView hold the open state. Keep, Escape and the backdrop push
on_cancel
.
Delete this workbook?
Its 3 sections and 40 submissions are removed for everyone.
Notes
-
The dialog is an
alertdialog: it names the action, says what happens in one line and offers "Keep it" next to a verb ("Delete", "Retire"), never "OK". -
Without a host on the page,
data-confirmkeeps phoenix_html's own browser prompt. -
In LiveView tests
data-confirmis ignored, so clicks go straight through; useSutraUI.Confirm.Test.confirm/2to run the verb of aconfirm_dialog.