Skip to content

Conversation

lezama
Copy link
Contributor

@lezama lezama commented Aug 28, 2025

Fixes #

Proposed changes

  • Switch Contact-Form submit control to Core Buttons – the block now inserts and recognises the Gutenberg Core Buttons → Button block, gaining all improvements made upstream and a more intuitive editing experience.
  • Variations & fallback – every form variation now uses a Core Button (<button type="submit"> with jetpack-form-submit-button class).
  • Interactivity – front-end render filter adds data-wp-class--is-submitting & data-wp-bind--aria-disabled so the Core Button integrates with Jetpack Forms’ submit/disable logic.
  • Spinner – loading indicator implemented by CSS ::after pseudo-element (no extra markup).
  • Backward compatibility – legacy forms that still contain a Jetpack Button continue to work unchanged; detection paths for wp-block-jetpack-button remain intact.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions

  1. Existing post smoke-test

    • Open a post containing a Contact Form created before this patch (uses Jetpack Button).
    • Confirm there are no editor errors; publish / update.
    • View front-end and submit the form – it should behave as it always did.
  2. New form

    • Insert a fresh Contact Form block.
    • Verify the submit control is a Core Button in a Core Buttons wrapper.
    • Publish and submit on the front-end – spinner, disable state and success/error handling should work.
  3. Variations

    • Insert each Contact-Form variation (RSVP, Registration, Feedback, etc.).
    • Confirm each uses a Core Button and submits correctly.
  4. Editor layout

    • Editing experience should respect the different core/block options when saving.

@lezama lezama requested a review from a team August 28, 2025 22:27
Copy link
Contributor

github-actions bot commented Aug 28, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the feature/replace-jetpack-buttons-with-core-buttons branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack feature/replace-jetpack-buttons-with-core-buttons

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@lezama lezama changed the title Forms: Replace Jetpack buttons with core buttons Forms: Replace Jetpack buttons with Core buttons Aug 28, 2025
Copy link
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • 🔴 Add a "[Status]" label (In Progress, Needs Review, ...).
  • 🔴 Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Aug 28, 2025
@lezama lezama changed the title Forms: Replace Jetpack buttons with Core buttons Forms: Use Core buttons instead of Jetpack buttons Aug 28, 2025
Copy link

jp-launch-control bot commented Aug 28, 2025

Code Coverage Summary

Coverage changed in 3 files.

File Coverage Δ% Δ Uncovered
projects/packages/forms/src/blocks/contact-form/class-contact-form-block.php 285/601 (47.42%) -0.97% 12 💔
projects/packages/forms/src/blocks/contact-form/edit.js 0/234 (0.00%) 0.00% 3 ❤️‍🩹
projects/packages/forms/src/contact-form/class-contact-form.php 586/1062 (55.18%) -0.10% 2 ❤️‍🩹

Full summary · PHP report · JS report

If appropriate, add one of these labels to override the failing coverage check: Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage.

[
'core/button',
{
text: __( 'Contact Us', 'jetpack-forms' ),
Copy link
Member

@simison simison Aug 29, 2025

Choose a reason for hiding this comment

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

Suggested change
text: __( 'Contact Us', 'jetpack-forms' ),
text: __( 'Contact us', 'jetpack-forms' ),

Good time to switch to sentence case while we're here.

Although this would need E2E update in calypso 🤦

https://github.com/Automattic/wp-calypso/blob/4c7fb9d7fc5047695e22b12a4708dbb9fb27f8e3/packages/calypso-e2e/src/lib/blocks/block-flows/contact-form.ts#L73

@simison simison requested a review from a team August 29, 2025 06:57
@simison
Copy link
Member

simison commented Sep 2, 2025

Great thing about using core buttons is that they will soon also support pseudo classes like :hover

lezama and others added 8 commits September 2, 2025 11:10
Replaces usage of the custom jetpack/button block with the core/buttons and core/button blocks for submit actions in the contact form. Updates block variations, editor logic, and server-side rendering to support and enhance compatibility with core/buttons, including interactivity attributes and error handling. This change improves alignment with WordPress core blocks and future-proofs the contact form implementation.
Introduces a spinner animation to the submit button when the form is submitting by adding CSS for a loading indicator and keyframes for the spinner effect.
@simison simison force-pushed the feature/replace-jetpack-buttons-with-core-buttons branch from be0699e to 04ea827 Compare September 2, 2025 08:11
@simison
Copy link
Member

simison commented Sep 2, 2025

Rebased

@enejb
Copy link
Member

enejb commented Sep 3, 2025

I noticed a couple of things while testing this PR.

  1. You are not able to set the width of the buttons block. ( the wrapper block ) This was unexpected since it removed the ability to place a field next to the button.
  2. You are able to put multiple button blocks inside the buttons wrapper block. This was unexpected since I would expect there to be only one submit button. I think a reset or cancel or clear button might work be useful but there was no way to create them. (this feature could be done in a future PR and not in this one)
  3. I didn't see the spinner that I am used to seeing when the form is submitting.

Nice work Miguel!

@lezama
Copy link
Contributor Author

lezama commented Sep 4, 2025

You are not able to set the width of the buttons block. ( the wrapper block ) This was unexpected since it removed the ability to place a field next to the button.

That was more of a hack. The idea is that you should use one of the stacking blocks, like columns or rows. Since we are using core buttons, we should take advantage of how they interact with those core layout blocks now.

@simison
Copy link
Member

simison commented Sep 4, 2025

Can we use the core button without its container?

Separately, do I remember wrong or does WP templating allow limiting the number of certain type blocks as inner blocks?

@lezama
Copy link
Contributor Author

lezama commented Sep 4, 2025

Can we use the core button without its container?

Looks like not: https://github.com/WordPress/gutenberg/blob/trunk/packages/block-library/src/button/block.json#L7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Contact Form Form block (also see Contact Form label) [Feature] Contact Form [Package] Forms [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants