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:
parent
3d32f2d92f
commit
3dafba72cc
1 changed files with 4 additions and 0 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in a new issue