Skip to content

Disable submit buttons while submitting to avoid duplicate api request. Closes #903#915

Merged
regulartim merged 3 commits intoGreedyBear-Project:developfrom
UsamaElareeny:formik-submit-disable
Mar 3, 2026
Merged

Disable submit buttons while submitting to avoid duplicate api request. Closes #903#915
regulartim merged 3 commits intoGreedyBear-Project:developfrom
UsamaElareeny:formik-submit-disable

Conversation

@UsamaElareeny
Copy link
Copy Markdown
Contributor

@UsamaElareeny UsamaElareeny commented Mar 2, 2026

Description

Disabled the submit buttons while submitting. This way it avoids multiple api requests triggered by the user.

Related issues

Related Issue #903

Type of change

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).
  • Chore (refactoring, dependency updates, CI/CD changes, code cleanup, docs-only changes).

Formalities

  • I have read and understood the rules about how to Contribute to this project.
  • I chose an appropriate title for the pull request in the form: <feature name>. Closes #999
  • My branch is based on develop.
  • The pull request is for the branch develop.
  • I have reviewed and verified any LLM-generated code included in this PR.

Docs and tests

  • I documented my code changes with docstrings and/or comments.
  • I have checked if my changes affect user-facing behavior that is described in the docs. If so, I also created a pull request in the docs repository.
  • Linter (Ruff) gave 0 errors. If you have correctly installed pre-commit, it does these checks and adjustments on your behalf.
  • I have added tests for the feature/bug I solved.
  • All the tests gave 0 errors.

Copilot AI review requested due to automatic review settings March 2, 2026 12:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a UI bug in the frontend auth flows where submit buttons could remain enabled while a Formik submission is in progress, allowing users to trigger duplicate API requests (Issue #903).

Changes:

  • Update submit button disabled logic to disable when the form is invalid or when formik.isSubmitting is true.
  • Apply the fix consistently across Login, Register, Reset Password, and the shared Email form component.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
frontend/src/components/auth/utils/EmailForm.jsx Disable submit while submitting to prevent duplicate resend-email requests.
frontend/src/components/auth/ResetPassword.jsx Disable submit while submitting to prevent duplicate reset-password requests.
frontend/src/components/auth/Register.jsx Disable submit while submitting to prevent duplicate registration requests.
frontend/src/components/auth/Login.jsx Disable submit while submitting to prevent duplicate login requests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Collaborator

@regulartim regulartim left a comment

Choose a reason for hiding this comment

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

Hey @UsamaElareeny ! Your fix is solid, minimal and correct (as far as I can see). 👍 Would you please react to Copilots suggestions regarding the tests? At least some of them seem to be valid.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@UsamaElareeny
Copy link
Copy Markdown
Contributor Author

Hi @regulartim , thanks for the fast feedback. Yes, they're pretty legit. I reacted to them :)

Copy link
Copy Markdown
Collaborator

@regulartim regulartim left a comment

Choose a reason for hiding this comment

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

Nice, thanks! :)

@regulartim regulartim merged commit 9918f7d into GreedyBear-Project:develop Mar 3, 2026
5 checks passed
cclts pushed a commit to cclts/GreedyBear that referenced this pull request Mar 11, 2026
Closes GreedyBear-Project#903 (GreedyBear-Project#915)

* Fix auth forms: disable submit buttons while submitting to avoid duplicated api request

* tests/awaited submission to settle before finishing the test + fixed some typos

* using async waitFor to avoid a race test
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.

3 participants