feat(ui): custom confirmation dialog replacing native window.confirm
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 51s

Single reusable dialog with a promise-based API: confirmAction({...})
returns Promise<boolean>. Supports title, optional message body,
confirm/cancel labels, and a 'destructive' flag that paints the confirm
button red.

Accessibility: Escape cancels, Enter confirms, confirm button auto-focus,
role=dialog + aria-labelledby, backdrop click = cancel.

Rolled out to: recipe delete, domain remove, profile delete, wishlist
remove. Native confirm() is gone from the codebase.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-17 17:15:21 +02:00
parent 3b1950713f
commit 1b9928f806
7 changed files with 229 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
<script lang="ts">
import { onMount } from 'svelte';
import { profileStore } from '$lib/client/profile.svelte';
import { confirmAction } from '$lib/client/confirm.svelte';
import type { WishlistEntry, SortKey } from '$lib/server/wishlist/repository';
let entries = $state<WishlistEntry[]>([]);
@@ -39,7 +40,13 @@
}
async function remove(entry: WishlistEntry) {
if (!confirm(`„${entry.title}" von der Wunschliste entfernen?`)) return;
const ok = await confirmAction({
title: 'Von der Wunschliste entfernen?',
message: `„${entry.title}" wird aus der Wunschliste entfernt. Das Rezept selbst bleibt gespeichert.`,
confirmLabel: 'Entfernen',
destructive: true
});
if (!ok) return;
await fetch(`/api/wishlist/${entry.recipe_id}`, { method: 'DELETE' });
await load();
}