-
Notifications
You must be signed in to change notification settings - Fork 842
Forms: replace jetpack buttons with core #46166
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
base: trunk
Are you sure you want to change the base?
Conversation
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Code Coverage SummaryCoverage changed in 3 files.
Full summary · PHP report · JS report Coverage check overridden by
Coverage tests to be added later
|
82662a1 to
ef3b913
Compare
| <!-- wp:jetpack/field-textarea {"label":"Notes"} /--> | ||
| <!-- wp:jetpack/button {"element":"button","text":"Book Appointment","lock":{"remove":true}} /--> | ||
| <!-- wp:button {"tagName":"button","type":"submit","className":"jetpack-form-submit-button"} --> | ||
| <div class="wp-block-button jetpack-form-submit-button"><button type="submit" class="wp-block-button__link wp-element-button">Book Appointment</button></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to specify the html?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we do. core/button relies on inner text for the text/value, while there is an attribute for it editor if you try to insert it it won't work.
This works:
<!-- wp:button -->
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button">HOLA</a></div>
<!-- /wp:button -->
This doesn't:
<!-- wp:button {"text":"HOLA"} -->
<!-- /wp:button -->
ef3b913 to
9efe006
Compare
| text: __( 'Submit', 'jetpack-forms' ), | ||
| type: 'submit', | ||
| tagName: 'button', | ||
| className: 'wp-block-jetpack-button jetpack-form-submit-button', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we necessarily need to add these classes? Since they're not from PHP, feels like we might not be able to trust them staying there anyway, so might as well not assume and use core classes instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't exactly follow what you mean by "not from PHP", but the answer might be simpler: we customize buttons heavily based on those classes.
For once I thought we could just remove them (classes and customizations), but then backwards compat hit: for the sake of simplicity we don't change old forms markup, so those buttons will still be there after this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| flex: 1 1 100%; | ||
| } | ||
|
|
||
| // .wp-block:not(.wp-block-buttons):not(.wp-block-button) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noting that the line needs removing before merging.
| } elseif ( $has_submit_button_block && ! $is_single_input_form ) { | ||
| // Place the error wrapper before the FIRST button block only to avoid duplicates (e.g., navigation buttons in multistep forms). | ||
| // Replace only the first occurrence. | ||
| // Replace only the first occurrence for both Jetpack and core Buttons blocks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be helpful for future to note here that old versions of Forms used to use Jetpack Button blocks
| animation: jp-spinner 0.75s linear infinite; | ||
| } | ||
|
|
||
| @keyframes jp-spinner { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a biggie, but jp-forms-spinner would be more specific to avoid colliding with any other Jetpack feature.
3bac19d to
add6cad
Compare
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.
Co-authored-by: Mikael Korpela <[email protected]>
Co-authored-by: Mikael Korpela <[email protected]>
Co-authored-by: Manzoor Wani <[email protected]>
…form-block.php Co-authored-by: Manzoor Wani <[email protected]>
0678483 to
9f31eb8
Compare

This is a takeover from #45007
Proposed changes:
Following the original PR, this is a simpler approach just using core/button to replace jetpack/button
Other information:
Jetpack product discussion
None
Does this pull request change what data or activity we track or use?
No
Testing instructions:
(verbatim from original PR)
Existing post smoke-test
New form
Variations
Editor layout