Skip to content

refactor(experience): add isSubmitting guard #7343

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

simeng-li
Copy link
Contributor

Summary

Add isSubmitting guard to all the form submission handler methods. This will prevent unexpected multi API requests.

Testing

Checklist

  • .changeset
  • unit tests
  • integration tests
  • necessary TSDoc comments

Sorry, something went wrong.

@simeng-li simeng-li requested review from a team and Copilot April 24, 2025 08:20
@github-actions github-actions bot added the enhancement Make it better label Apr 24, 2025
Copy link

github-actions bot commented Apr 24, 2025

COMPARE TO master

Total Size Diff 📈 +512 Bytes

Diff by File
Name Diff
packages/experience/src/components/IdentifierRegisterForm/index.test.tsx 📈 +91 Bytes
packages/experience/src/components/IdentifierRegisterForm/index.tsx 📈 +71 Bytes
packages/experience/src/components/IdentifierSignInForm/index.tsx 📈 +71 Bytes
packages/experience/src/components/PasswordSignInForm/index.tsx 📈 +71 Bytes
packages/experience/src/components/SingleSignOnForm/index.tsx 📈 +65 Bytes
packages/experience/src/containers/SetPassword/Lite.tsx 📈 +65 Bytes
packages/experience/src/containers/SetPassword/SetPassword.tsx 📈 +65 Bytes
packages/experience/src/pages/Continue/IdentifierProfileForm/index.tsx 📈 +65 Bytes
packages/experience/src/pages/ForgotPassword/ForgotPasswordForm/index.tsx 📈 +65 Bytes
packages/experience/src/pages/SignInPassword/PasswordForm/index.tsx 📈 +65 Bytes

Copy link

@Copilot 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 introduces an isSubmitting guard to all form submission handlers to prevent multiple API requests when a form is submitted repeatedly in quick succession.

  • Added an early return check using isSubmitting in various form components.
  • Updated dependency arrays of useCallback hooks to include isSubmitting.
  • Covers sign in, password reset, registration, and SSO forms to ensure consistent submission prevention.

Reviewed Changes

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

Show a summary per file
File Description
packages/experience/src/pages/SignInPassword/PasswordForm/index.tsx Added isSubmitting guard and updated hook dependencies.
packages/experience/src/pages/ForgotPassword/ForgotPasswordForm/index.tsx Introduced isSubmitting check in the submission handler and updated dependencies.
packages/experience/src/pages/Continue/IdentifierProfileForm/index.tsx Added isSubmitting guard to prevent duplicate submissions.
packages/experience/src/containers/SetPassword/SetPassword.tsx Inserted isSubmitting guard and updated callback dependencies.
packages/experience/src/containers/SetPassword/Lite.tsx Added isSubmitting check and updated dependency array.
packages/experience/src/components/SingleSignOnForm/index.tsx Inserted isSubmitting guard before submission handling.
packages/experience/src/components/PasswordSignInForm/index.tsx Added guard and updated dependencies to include isSubmitting.
packages/experience/src/components/IdentifierSignInForm/index.tsx Inserted isSubmitting check and updated dependencies accordingly.
packages/experience/src/components/IdentifierRegisterForm/index.tsx Integrated isSubmitting guard and updated hook dependencies.
Comments suppressed due to low confidence (9)

packages/experience/src/pages/SignInPassword/PasswordForm/index.tsx:71

  • Ensure that the isSubmitting flag is properly managed (set to true when submission starts and reset after completion) to effectively prevent duplicate submissions.
if (isSubmitting) {

packages/experience/src/pages/ForgotPassword/ForgotPasswordForm/index.tsx:62

  • Verify that the isSubmitting state is correctly updated around the form submission to avoid unintentional blocking of submissions.
if (isSubmitting) {

packages/experience/src/pages/Continue/IdentifierProfileForm/index.tsx:65

  • Confirm that the isSubmitting flag is effectively toggled during the async submission process to ensure the guard works as expected.
if (isSubmitting) {

packages/experience/src/containers/SetPassword/SetPassword.tsx:60

  • Make sure that the isSubmitting state is set at the beginning of submission and reset afterwards to fully prevent multiple API calls.
if (isSubmitting) {

packages/experience/src/containers/SetPassword/Lite.tsx:46

  • Double-check that the isSubmitting flag is correctly updated in the component's lifecycle so that duplicate submissions are reliably blocked.
if (isSubmitting) {

packages/experience/src/components/SingleSignOnForm/index.tsx:58

  • Ensure that isSubmitting is consistently managed in the submission process to avoid missing state updates leading to duplicate API calls.
if (isSubmitting) {

packages/experience/src/components/PasswordSignInForm/index.tsx:66

  • Check that the isSubmitting flag is being updated appropriately during form submission so the guard prevents unintended repeat calls.
if (isSubmitting) {

packages/experience/src/components/IdentifierSignInForm/index.tsx:73

  • Confirm that the isSubmitting state is properly set and cleared during submission to guarantee that the duplicate submission guard works correctly.
if (isSubmitting) {

packages/experience/src/components/IdentifierRegisterForm/index.tsx:66

  • Validate that isSubmitting is managed properly around the submission lifecycle to robustly prevent multiple simultaneous API calls.
if (isSubmitting) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Make it better size/s
Development

Successfully merging this pull request may close these issues.

2 participants