-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
base: main
Are you sure you want to change the base?
Help to Identify which button is clicked when the user has multiple s… #3859
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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:
|
@probablyup @jaredpalmer |
@probablyup @jaredpalmer soft reminder. |
const handleSubmit = useEventCallback(function | ||
(e?: React.FormEvent<HTMLFormElement> | any ,extraArgs?: any) { | ||
|
||
extraArgsOnSubmit.current=extraArgs; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@probablyup a soft reminder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@probablyup a soft reminder.
…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.