Skip to content

Conversation

@lezama
Copy link
Contributor

@lezama lezama commented Aug 28, 2025

Resolves FORMS-83

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
@github-actions
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
@github-actions
Copy link
Contributor

github-actions bot commented Aug 28, 2025

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
@jp-launch-control
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/edit.tsx 0/274 (0.00%) 0.00% 3 ❤️‍🩹
projects/packages/forms/src/contact-form/class-contact-form.php 893/1297 (68.85%) -0.11% 2 ❤️‍🩹
projects/packages/forms/src/blocks/contact-form/class-contact-form-block.php 517/604 (85.60%) 3.02% -16 💚

Full summary · PHP report · JS report

@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

@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

Copy link
Contributor

@CGastrell CGastrell left a comment

Choose a reason for hiding this comment

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

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

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

❌ Spinner didn't show, neither does disabled state

Variations

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

Editor layout

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

👀 Unsure to what extent this means. I can adjust all styling options. Though on Attributes I see this on all opions, and setting "text" messes with the button label:
image

❌ Changing the URL Attribute makes the button not render on frontend.

👀 Input styles are not shared with the button, should it?

@CGastrell CGastrell force-pushed the feature/replace-jetpack-buttons-with-core-buttons branch from 7065a4b to 71ae94b Compare September 16, 2025 14:55
@CGastrell
Copy link
Contributor

Added some tests and fixed the class and state binding

@CGastrell
Copy link
Contributor

Added the same edits to useFormWrapper hook so to use core/buttons

Copy link
Member

@manzoorwanijk manzoorwanijk left a comment

Choose a reason for hiding this comment

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

A couple of suggestions for minor code quality improvements.

@github-actions
Copy link
Contributor

This PR has been marked as stale. This happened because:

  • It has been inactive for the past 3 months.
  • It hasn't been labeled `[Pri] BLOCKER`, `[Pri] High`, `[Status] Keep Open`, etc.

If this PR is still useful, please do a [trunk merge or rebase](https://github.com/Automattic/jetpack/blob/trunk/docs/git-workflow.md#keeping-your-branch-up-to-date) and otherwise make sure it's up to date and has clear testing instructions. You may also want to ping possible reviewers in case they've forgotten about it. Please close this PR if you think it's not valid anymore — if you do, please add a brief explanation.

If the PR is not updated (or at least commented on) in another month, it will be automatically closed.

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.
@CGastrell CGastrell force-pushed the feature/replace-jetpack-buttons-with-core-buttons branch from 3d4ef8c to fac10d5 Compare November 28, 2025 16:36
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. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants