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

Help to Identify which button is clicked when the user has multiple s… #3859

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

toqeer-hussain
Copy link

…ubmit button actions like

(Save and Continue, Save, Save for Future, Save and Exit ).

The user passes two arguments to handleSubmit the first parameter is FormEvent and the second parameter is an extra argument. Users can pass only an extra argument as first a parameter.

The extra argument is passed and 3rd argument to the onSubmit. That helps the user to identify which action he needs to proceed based upon.

…ubmit button actions like

(Save and Continue, Save, Save for Future, Save and Exit ).

The user passes two arguments to handleSubmit the first parameter is FormEvent and the second parameter is an extra argument.
Users can pass only an extra argument as first a parameter.

The extra argument is passed and 3rd argument to the onSubmit. That helps the user to identify which action he needs to proceed based upon.
@changeset-bot
Copy link

changeset-bot bot commented Aug 5, 2023

⚠️ No Changeset found

Latest commit: 5391c8f

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

@vercel
Copy link

vercel bot commented Aug 5, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
formik-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 5, 2023 4:18pm

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 5, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 5391c8f:

Sandbox Source
Formik TypeScript Playground (forked) Configuration

@toqeer-hussain
Copy link
Author

@probablyup @jaredpalmer
Can you please review this PR because it's pending your approval?
If there is any need of improvement Please guide me.

@toqeer-hussain
Copy link
Author

@probablyup @jaredpalmer soft reminder.

const handleSubmit = useEventCallback(function
(e?: React.FormEvent<HTMLFormElement> | any ,extraArgs?: any) {

extraArgsOnSubmit.current=extraArgs;
Copy link
Collaborator

@quantizor quantizor Sep 11, 2023

Choose a reason for hiding this comment

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

What if we just passed the event itself when available and let the consumer decide what they want to do with it?

Copy link
Author

Choose a reason for hiding this comment

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

First of all, I was thinking the same. But this would bind the user to call the handleSubmit on the Submit Button. What if the user wants to directly call the handleSubmit then I think the above-implemented strategy would work fine.

One more think if we pass the event it would make it more cumbersome for user to deal with the nativeEvent instead deal with a string/object.

Copy link
Author

Choose a reason for hiding this comment

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

@probablyup a soft reminder.

Copy link
Author

Choose a reason for hiding this comment

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

@probablyup a soft reminder.

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.

None yet

2 participants