Skip to content

Add submitting state to page store  #7120

@KoichiKiyokawa

Description

@KoichiKiyokawa

Describe the problem

First, thank you for all of your work in SvelteKit.
It's common to disable the submit button during form submission to prevent users from submitting multiple times.
But now, we need some boilerplate code to do it. cf) #7041
It would be nice if SvelteKit provides the submitting state by page store.

Describe the proposed solution

  • $page.formSubmitting ?
  • $page.form.submitting ?
  • and so on
<script>
import { page } from '$app/store'
</script>

<button disable={$page.formSubmitting}>submit</button>

Alternatives considered

No response

Importance

nice to have

Additional Information

FYI: Remix can handle it by the followings,

function SubmitButton() {
  const transition = useTransition();

  return <button type="submit" disable={transition.state === "submitting"}>submit</button>;
}

https://remix.run/docs/en/v1/api/remix#transitionstate

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions