fix(12-03): reset discussion composer from htmx form

This commit is contained in:
Arthur Belleville 2026-05-16 10:32:28 +02:00
parent 1034efcec4
commit 409245eac0
No known key found for this signature in database
2 changed files with 2 additions and 1 deletions

View file

@ -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)
}

View file

@ -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)