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

Fixes the formik submit handler returning a promise for synchronous submit handlers which in turn immediately sets the isSubmitting to false. #2357

Conversation

deepakjosp
Copy link
Contributor

@deepakjosp deepakjosp commented Oct 24, 2024

Description

  • The async handleSubmit will always return a Promise, even if the submit handler inside doesn’t return one. This leads to unexpected bugs, as the Promise resolves immediately when using the mutate function of useMutation while the API call might still be in progress.
  • In Formik, if a Promise is returned, it waits for it to resolve before setting isSubmitting to false. In our case, this happens immediately after the button click.
  • Since we weren’t returning the result of the submit handler, it consistently returned a Promise once the handler executed, which caused this behavior.

Checklist

  • I have made corresponding changes to the documentation.
  • I have updated the types definition of modified exports.
  • I have verified the functionality in some of the neeto web-apps.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added proper data-cy and data-testid attributes.
  • I have added the necessary label (patch/minor/major - If package publish
    is required).

Reviewers

…ubmit handlers which in turn immediately sets the isSubmitting to false.
@neetodeploy neetodeploy bot temporarily deployed to neeto-ui-1f4k-pr-2357 October 24, 2024 04:28 Inactive
@deepakjosp deepakjosp added the patch Releases small requests or bug fixes. label Oct 24, 2024
@deepakjosp
Copy link
Contributor Author

@josephmathew900 _a please review.

Copy link
Contributor

@josephmathew900 josephmathew900 left a comment

Choose a reason for hiding this comment

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

LGTM

@josephmathew900 josephmathew900 merged commit 12a2209 into main Oct 24, 2024
1 check passed
@josephmathew900 josephmathew900 deleted the 2334-save-changes-button-should-be-disabled-in-the-actionblock-component branch October 24, 2024 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Releases small requests or bug fixes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Save changes" button should be disabled in the ActionBlock component
2 participants