From 39d1e4ca04a9468d0b9f37cb2d66d64c05dd4a26 Mon Sep 17 00:00:00 2001 From: Jay Stothard Date: Mon, 3 Jun 2024 17:12:03 +0100 Subject: [PATCH] Update example for auto submit to prevent page refreshes Currently, the example shown for auto form submission can cause the page to reload as the form `onsubmit` handler isn't called by `form.submit` [see MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit). To call the form `onsubmit` you need to use `form.requestSubmit` --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 57c36b7..23be88a 100644 --- a/README.md +++ b/README.md @@ -277,7 +277,7 @@ export default function Page() {
formRef.current?.submit()} + onComplete={() => formRef.current?.requestSubmit()} // ... or focus the button like as you wish onComplete={() => buttonRef.current?.focus()} />