Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update submission.ts #757

Closed
wants to merge 2 commits into from
Closed

Conversation

lifeiscontent
Copy link
Contributor

fixes: #756

Copy link

changeset-bot bot commented Aug 30, 2024

⚠️ No Changeset found

Latest commit: 8088117

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

pkg-pr-new bot commented Aug 30, 2024

commit: 8088117

@conform-to/dom

pnpm add https://pkg.pr.new/@conform-to/dom@757

@conform-to/react

pnpm add https://pkg.pr.new/@conform-to/react@757

@conform-to/validitystate

pnpm add https://pkg.pr.new/@conform-to/validitystate@757

@conform-to/yup

pnpm add https://pkg.pr.new/@conform-to/yup@757

@conform-to/zod

pnpm add https://pkg.pr.new/@conform-to/zod@757

Open in Stackblitz

More templates

Comment on lines +250 to +263
const extraError =
'formErrors' in options || 'fieldErrors' in options
? normalize<Record<string, FormError | null>>({
'': options.formErrors ?? null,
...options.fieldErrors,
})
: null;
const error =
context.error || extraError
? {
...context.error,
...extraError,
}
: undefined;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edmundhung I'm not sure if it makes sense to show the error status, but I kept it in because I'm not sure what the expectations are

@lifeiscontent
Copy link
Contributor Author

@edmundhung I can fix tests if you think this is an appropriate change

@lifeiscontent
Copy link
Contributor Author

nevermind, I figured out how to do it.

this is the code that works with submission.reply({resetForm: true})

  useEffect(() => {
    if (
      fetcher.state === "idle" &&
      fetcher.data &&
      fetcher.data.status !== "error"
    ) {
      onFinish();
    }
  }, [fetcher.data, fetcher.state, onFinish]);

where onFinish should be called in the scenario you want to close a form drawer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

resetForm: true resets status
1 participant