Skip to content

Conversation

@iamdharmesh
Copy link
Collaborator

Description of the Change

This PR fixes the form data reset issue by ensuring that form data persists when validation fails.
It only addresses the form reset issue for JavaScript-based submissions, as HTML form submission will be removed in version 1.7.0 (already removed in #126)

Note

This PR resolves the issue by updating the regex to correctly determine whether the response is an error or a success based on the class in the returned markup. Ideally, this should be handled by updating the code to return a proper JSON response, but for now, the fix is applied to the existing code, with potential improvements planned for the future.

Closes #100

How to test the Change

  1. Enable "Use JavaScript Support?" from the settings page.
  2. Add a subscription form using a block, shortcode, or widget.
  3. Enter an invalid value in the form (e.g., a blank email field).
  4. Press submit and verify that:
    • The validation error appears.
    • The entered form data persists.
  5. Enter valid data, submit the form, and verify that:
    • The success message appears.
    • The form data resets.

Changelog Entry

Fixed - Ensure that form data persists when validation fails.

Credits

Props @MaxwellGarceau @iamdharmesh

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@iamdharmesh iamdharmesh self-assigned this Mar 21, 2025
@iamdharmesh iamdharmesh added this to the 1.7.0 milestone Mar 21, 2025
@github-actions github-actions bot added the needs:code-review This requires code review. label Mar 21, 2025
@iamdharmesh iamdharmesh requested a review from dkotter March 21, 2025 10:48
Copy link
Collaborator

@qasumitbagthariya qasumitbagthariya left a comment

Choose a reason for hiding this comment

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

QA Update ❌


@iamdharmesh

When two Mailchimp forms (including a widget) are present on the same page, the entered data does not persist after submission.

Steps to Reproduce:

  1. Add two Mailchimp forms (one as a form and one as a widget) on the same page.
  2. Fill out the form fields in both forms.
  3. Submit one of the forms.
  4. Observe that the data in the other form is lost.
Screen.Recording.2025-03-24.at.4.02.23.PM.mov

Testing Environment

  • WordPress: 6.7.2
  • Theme: Storefront 4.6.1
  • Theme: Twenty Twenty-Four 1.3
  • PHP: 8.0.30
  • Web Server: Nginx 1.20.2
  • Browser: Chrome
  • OS: macOS 15.2
  • Branch: fix/100

@qasumitbagthariya
Copy link
Collaborator

QA Update ✅


I have verified this PR in the fix/100 branch, which has been fixed and is functioning as intended.

I tested the following on this branch:

  • Form persists when validation fails
Screen.Recording.2025-03-25.at.7.26.54.PM.mov

Testing Environment

  • WordPress: 6.7.2
  • Theme: Storefront 4.6.1
  • Theme: Twenty Twenty-Four 1.3
  • PHP: 8.0.30
  • Web Server: Nginx 1.20.2
  • Browser: Chrome
  • OS: macOS 15.2
  • Branch: fix/100

Steps to Test- As mentioned in the PR description.
Test Results - It is working as expected.
Functional Demo / Screencast -
Special Notes - Ready for code review (Woo)
Testing Document status:
Cases related to this Issue/PR are added to the Critical Flow Wiki pages:

  • Yes
  • Not Required/Applicable for this PR

@iamdharmesh
Copy link
Collaborator Author

Note: We need to make a minor change by adding a class (similar to what we added in the mailchimp_sf_signup_form function in this PR) to the markup file of the updated block (#126) once either of these PRs is merged into the develop branch.

@iamdharmesh
Copy link
Collaborator Author

Note: We need to make a minor change by adding a class (similar to what we added in the mailchimp_sf_signup_form function in this PR) to the markup file of the updated block (#126) once either of these PRs is merged into the develop branch.

Added in dd812f2

@qasumitbagthariya
Copy link
Collaborator

Regression / Smoke Test Report ✅

Tested with the smoke-testing branch, it works as expected, similar to the fix-specific branch.

Testing Environment

  • WordPress: 6.7.2
  • Theme: Storefront 4.6.0
  • Theme: Twenty Twenty-Four 1.3
  • PHP: 8.0.30
  • Web Server: Nginx 1.20.2
  • Browser: Chrome
  • OS: macOS 15.2
  • Branch: smoke-testing

Next Step- Ready to Merge 🚀

@github-actions github-actions bot added the needs:refresh This requires a refreshed PR to resolve. label Apr 7, 2025
@github-actions github-actions bot removed the needs:refresh This requires a refreshed PR to resolve. label Apr 7, 2025
@vikrampm1 vikrampm1 merged commit 1468478 into develop Apr 7, 2025
12 checks passed
@vikrampm1 vikrampm1 mentioned this pull request Apr 7, 2025
29 tasks
@dkotter dkotter deleted the fix/100 branch May 8, 2025 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:code-review This requires code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Form data is not persisted when validation is not met

6 participants