fix(04-WR-02): set HX-Retarget/HX-Reswap on 422 path in TaskCreateHandler

Without these headers, HTMX used the form's own hx-target="#column-{status}"
+ hx-swap="beforeend", appending the error form into the task column and
destroying all visible task cards. The error form now lands back in the
add-task slot where it belongs.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Arthur Belleville 2026-05-15 10:19:10 +02:00
parent 3d32f2d92f
commit 3dafba72cc
No known key found for this signature in database

View file

@ -147,6 +147,10 @@ func TaskCreateHandler(deps TasksDeps) http.HandlerFunc {
if errs.Title != "" {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
if r.Header.Get("HX-Request") == "true" {
w.Header().Set("HX-Retarget", "#add-task-slot-"+statusStr)
w.Header().Set("HX-Reswap", "innerHTML")
}
w.WriteHeader(http.StatusUnprocessableEntity)
if r.Header.Get("HX-Request") == "true" {
_ = templates.TaskCreateFormFragment(