From 409245eac0aa15a1b54be2efe2347611d7784222 Mon Sep 17 00:00:00 2001 From: Arthur Belleville Date: Sat, 16 May 2026 10:32:28 +0200 Subject: [PATCH] fix(12-03): reset discussion composer from htmx form --- backend/internal/web/handlers_discussion_test.go | 2 +- backend/templates/discussion.templ | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/internal/web/handlers_discussion_test.go b/backend/internal/web/handlers_discussion_test.go index f74cbd2..d264142 100644 --- a/backend/internal/web/handlers_discussion_test.go +++ b/backend/internal/web/handlers_discussion_test.go @@ -90,7 +90,7 @@ func TestDiscussionTabRendersHistoryAndComposer(t *testing.T) { t.Fatalf("GET discussion tab status = %d; want 200; body: %.500s", rec.Code, rec.Body.String()) } body := rec.Body.String() - for _, want := range []string{"Discussion", "1 participant", user.Email, "May 16, 2026", "May 17, 2026", "Message", "Write a message...", "Send message"} { + for _, want := range []string{"Discussion", "1 participant", user.Email, "May 16, 2026", "May 17, 2026", "Message", "Write a message...", "Send message", "hx-on::after-request", "this.reset()"} { if !strings.Contains(body, want) { t.Errorf("discussion tab missing %q; body: %.1000s", want, body) } diff --git a/backend/templates/discussion.templ b/backend/templates/discussion.templ index e868e37..500b0ae 100644 --- a/backend/templates/discussion.templ +++ b/backend/templates/discussion.templ @@ -63,6 +63,7 @@ templ DiscussionComposer(tablo sqlc.Tablo, form DiscussionForm, errs DiscussionE hx-post={ DiscussionPostURL(tablo.ID) } hx-target="#discussion-messages" hx-swap="beforeend" + hx-on::after-request="if (event.detail.xhr.status >= 200 && event.detail.xhr.status < 300) this.reset()" class="border-t border-slate-200 pt-4" > @ui.CSRFField(csrfToken)