fix(stats): stabilize newsletter form reset

This commit is contained in:
Adam 2026-05-29 09:03:16 -05:00
commit 0a60dbdcee
No known key found for this signature in database
GPG key ID: 9CB48779AF150E75

View file

@ -1648,15 +1648,16 @@ function SubscribeModal(props: { onClose: () => void }) {
method="post" method="post"
onSubmit={(event) => { onSubmit={(event) => {
event.preventDefault() event.preventDefault()
const form = event.currentTarget
setStatus("pending") setStatus("pending")
setMessage("") setMessage("")
fetch(`${import.meta.env.BASE_URL}api/newsletter`, { fetch(`${import.meta.env.BASE_URL}api/newsletter`, {
method: "POST", method: "POST",
body: new FormData(event.currentTarget), body: new FormData(form),
}).then( }).then(
async (response) => { async (response) => {
if (response.ok) { if (response.ok) {
event.currentTarget.reset() form.reset()
setStatus("success") setStatus("success")
return return
} }