fix(admin): delete user button now works reliably #279

Merged
marcel merged 1 commits from fix/delete-user into main 2026-04-20 08:43:16 +02:00
Owner

Summary

  • Replaces the type=button + requestSubmit() pattern on the delete form with a type=submit button and an async use:enhance callback — the pattern the confirm service was designed for and documents in its JSDoc
  • The enhance callback awaits the confirm dialog, calls cancel() if the user rejects, and calls unsaved.clearOnSuccess() before proceeding so that beforeNavigate can't silently block the post-delete redirect
  • Removes the now-unnecessary deleteFormEl state variable and handleDelete function
  • Updates the spec's enhance mock to support async callbacks and rewrites the three delete-confirmation tests to assert on cancel() calls instead of requestSubmit() spies

Closes #277

Test plan

  • Open a user's detail page in the admin panel
  • Click "Löschen…" — confirm dialog should appear
  • Cancel → no deletion, page unchanged
  • Click again, confirm → user is deleted and page navigates to /admin/users, deleted user gone from list
  • Repeat with the edit form dirty (type something) before clicking delete — redirect should still happen after confirming
  • npx vitest run src/routes/admin/users — all 49 tests pass

🤖 Generated with Claude Code

## Summary - Replaces the `type=button` + `requestSubmit()` pattern on the delete form with a `type=submit` button and an async `use:enhance` callback — the pattern the confirm service was designed for and documents in its JSDoc - The enhance callback awaits the confirm dialog, calls `cancel()` if the user rejects, and calls `unsaved.clearOnSuccess()` before proceeding so that `beforeNavigate` can't silently block the post-delete redirect - Removes the now-unnecessary `deleteFormEl` state variable and `handleDelete` function - Updates the spec's enhance mock to support async callbacks and rewrites the three delete-confirmation tests to assert on `cancel()` calls instead of `requestSubmit()` spies Closes #277 ## Test plan - [ ] Open a user's detail page in the admin panel - [ ] Click "Löschen…" — confirm dialog should appear - [ ] Cancel → no deletion, page unchanged - [ ] Click again, confirm → user is deleted and page navigates to `/admin/users`, deleted user gone from list - [ ] Repeat with the edit form dirty (type something) before clicking delete — redirect should still happen after confirming - [ ] `npx vitest run src/routes/admin/users` — all 49 tests pass 🤖 Generated with [Claude Code](https://claude.com/claude-code)
marcel changed target branch from main to feat/issue-271-dashboard-redesign 2026-04-19 19:11:31 +02:00
marcel changed target branch from feat/issue-271-dashboard-redesign to main 2026-04-20 07:45:22 +02:00
marcel added 1 commit 2026-04-20 07:52:36 +02:00
fix(admin): wire delete-user button via enhance callback instead of requestSubmit()
Some checks failed
CI / Unit & Component Tests (pull_request) Failing after 2m46s
CI / OCR Service Tests (pull_request) Successful in 36s
CI / Backend Unit Tests (pull_request) Failing after 2m52s
CI / Unit & Component Tests (push) Failing after 2m51s
CI / OCR Service Tests (push) Successful in 40s
CI / Backend Unit Tests (push) Failing after 2m58s
b6466fcd95
The delete button used type=button + requestSubmit() to trigger the form,
which did not reliably fire SvelteKit's enhance submit listener. Replaced
with a type=submit button and an async enhance callback that guards with
the confirm dialog and calls cancel() on rejection.

Also clears the unsaved-changes dirty flag before the redirect so
beforeNavigate doesn't silently block the post-delete navigation.

Closes #277

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
marcel force-pushed fix/delete-user from 5b15991cf3 to b6466fcd95 2026-04-20 07:52:36 +02:00 Compare
marcel merged commit b6466fcd95 into main 2026-04-20 08:43:16 +02:00
marcel deleted branch fix/delete-user 2026-04-20 08:43:17 +02:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: marcel/familienarchiv#279