Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2de4572
Switch contact form submit button to core/buttons block
lezama Aug 28, 2025
55b84dc
simpler
lezama Aug 28, 2025
90b6208
Restrict flex styling to specific wp-block elements
lezama Aug 28, 2025
c6c29db
Add spinner animation for submitting form button
lezama Aug 28, 2025
97e305f
Restrict tag processing to button and update submit styles
lezama Aug 28, 2025
65492dd
changelog
lezama Aug 28, 2025
6d966af
Update projects/packages/forms/src/blocks/contact-form/variations.js
lezama Aug 29, 2025
fcb80ce
Refactor render_submit_button to improve clarity
lezama Aug 29, 2025
2a35cb1
Update projects/packages/forms/src/blocks/contact-form/variations.js
lezama Sep 15, 2025
0b33c81
add some tests to improve coverage
CGastrell Sep 16, 2025
a040e5f
fix disabled and submitting states
CGastrell Sep 16, 2025
ac04f6f
update tests after attribute addition
CGastrell Sep 16, 2025
12cad23
modify useformwrapper to use core/buttons as well
CGastrell Sep 16, 2025
17511fa
Apply suggestion from @manzoorwanijk
lezama Sep 17, 2025
de44c89
Update projects/packages/forms/src/blocks/contact-form/class-contact-…
lezama Sep 17, 2025
296f63c
change patterns to use core buttons
CGastrell Sep 17, 2025
a307fdd
switch core/buttons for core/button
CGastrell Dec 2, 2025
cb3c2b7
changelog
CGastrell Dec 2, 2025
5e86e55
make core buttons take the same styles as previous jetpack buttons
CGastrell Dec 2, 2025
a7553f9
avoid margins on buttons
CGastrell Dec 3, 2025
59aced3
add conditional so php8.5 test doesn't fail due to deprecated method
CGastrell Dec 5, 2025
522de92
fix/remove comments
CGastrell Dec 11, 2025
118966c
search/replace the right blocks, it's now button, not buttons
CGastrell Dec 11, 2025
dac8ee5
more specific naming for the button spinner
CGastrell Dec 11, 2025
71497da
include wp-block-button on all button customizations
CGastrell Dec 15, 2025
6a49d3e
remove extra top padding on animated inputs, while it looks more cram…
CGastrell Dec 15, 2025
2e851ee
leave a consistent comment for the future about how/why we use the bu…
CGastrell Dec 16, 2025
a9f8868
search for button, not buttons
CGastrell Dec 16, 2025
9d01a53
move button preparation code inside the form markup process
CGastrell Dec 17, 2025
b258bd2
remove now unneeded extra class on buttons
CGastrell Dec 17, 2025
cf1d857
use special spinner only on old button instances, core blocks hold th…
CGastrell Dec 17, 2025
cb0f84f
be more specific on docblock description
CGastrell Dec 17, 2025
d203a2b
remove test after removing method
CGastrell Dec 18, 2025
bae3df4
use core/button on variation templates
CGastrell Dec 22, 2025
8e11ca4
fix iteration mishap
CGastrell Dec 22, 2025
a716098
deal with legacy buttons and use the same ::after animated spinner st…
CGastrell Dec 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions projects/packages/forms/changelog/add-core-button-submit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Forms: allow using the Gutenberg Core Button block as the submit control in Contact Form. The block gets the same interactivity bindings and loading spinner as the Jetpack Button, and all form variations now insert a core button by default.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: changed

Forms: use core/button instead of jetpack/button
27 changes: 18 additions & 9 deletions projects/packages/forms/src/blocks/contact-form/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,13 @@ function JetpackContactFormEdit( {
[ clientId, steps ]
);

const submitButton = useFindBlockRecursively(
clientId,
block => block.name === 'jetpack/button'
const findButtonsBlock = useCallback(
block => block.name === 'core/button' || block.name === 'jetpack/button',
[]
);

const submitButton = useFindBlockRecursively( clientId, findButtonsBlock );

const { postTitle, hasAnyInnerBlocks, postAuthorEmail, selectedBlockClientId, onlySubmitBlock } =
useSelect(
select => {
Expand All @@ -236,6 +238,11 @@ function JetpackContactFormEdit( {
const { getUser } = select( coreStore );
const innerBlocksData = getBlocks( clientId );

const isSingleButtonBlock =
innerBlocksData.length === 1 &&
( innerBlocksData[ 0 ].name === 'core/button' ||
innerBlocksData[ 0 ].name === 'jetpack/button' );

const title = getEditedPostAttribute( 'title' );
const authorId = getEditedPostAttribute( 'author' );
const authorEmail = authorId && getUser( authorId )?.email;
Expand All @@ -245,8 +252,7 @@ function JetpackContactFormEdit( {
hasAnyInnerBlocks: innerBlocksData.length > 0,
postAuthorEmail: authorEmail,
selectedBlockClientId: selectedStepBlockId,
onlySubmitBlock:
innerBlocksData.length === 1 && innerBlocksData[ 0 ].name === 'jetpack/button',
onlySubmitBlock: isSingleButtonBlock,
};
},
[ clientId ]
Expand Down Expand Up @@ -344,7 +350,7 @@ function JetpackContactFormEdit( {
// Find the submit button
const submitButtonIndex = currentInnerBlocks.findIndex(
block =>
block.name === 'jetpack/button' &&
( block.name === 'core/button' || block.name === 'jetpack/button' ) &&
( block.attributes?.customVariant === 'submit' || block.attributes?.element === 'button' )
);

Expand Down Expand Up @@ -479,7 +485,9 @@ function JetpackContactFormEdit( {

// Helper functions
const findButtonBlock = () => {
const buttonIndex = currentInnerBlocks.findIndex( block => block.name === 'jetpack/button' );
const buttonIndex = currentInnerBlocks.findIndex(
block => block.name === 'core/button' || block.name === 'jetpack/button'
);
return buttonIndex !== -1
? {
block: currentInnerBlocks[ buttonIndex ],
Expand Down Expand Up @@ -720,9 +728,10 @@ function JetpackContactFormEdit( {
// Ensure we have a submit button at the end of the form.
if ( ! finalSubmitButton ) {
// Create a fresh submit button if none was found.
finalSubmitButton = createBlock( 'jetpack/button', {
element: 'button',
finalSubmitButton = createBlock( 'core/button', {
text: __( 'Submit', 'jetpack-forms' ),
type: 'submit',
tagName: 'button',
} );
}

Expand Down
19 changes: 18 additions & 1 deletion projects/packages/forms/src/blocks/contact-form/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,18 @@
}

.wp-block {
flex: 1 1 100%;
flex: 0 0 100%;
margin-top: 0;
margin-bottom: 0;
max-width: 100%;

&.wp-block-button,
&.wp-block-jetpack-button {
flex: 0 0 auto;
min-height: var(--jetpack--contact-form--input-height, auto);
align-self: flex-end;
line-height: 1;
margin-block: 0;

.wp-block-button__link {
min-height: var(--jetpack--contact-form--input-height, auto);
Expand All @@ -86,6 +88,7 @@
box-sizing: border-box;
}

&.wp-block-button__width-25,
&.jetpack-field__width-25 {
flex: 1 1 calc(25% - calc(var(--wp--style--block-gap, 1.5rem) * 1));
max-width: 25%;
Expand All @@ -96,16 +99,30 @@
max-width: 33.33%;
}

&.wp-block-button__width-50,
&.jetpack-field__width-50 {
flex: 1 1 calc(50% - calc(var(--wp--style--block-gap, 1.5rem) * 1));
max-width: 50%;
}

&.wp-block-button__width-75,
&.jetpack-field__width-75 {
flex: 1 1 calc(75% - calc(var(--wp--style--block-gap, 1.5rem) * 1));
max-width: 75%;
}

&.wp-block-button__width-100 {
flex: 1 1 100%;
max-width: 100%;
}

&.wp-block-button.has-custom-width {

.wp-block-button__link {
width: 100%;
}
}

&.jetpack-field__width-auto {
flex: 1 1 0;
}
Expand Down
72 changes: 36 additions & 36 deletions projects/packages/forms/src/blocks/contact-form/variations.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ const variations = [
],
],
[
'jetpack/button',
'core/button',
{
text: __( 'Contact Us', 'jetpack-forms' ),
element: 'button',
lock: { remove: true },
text: __( 'Contact us', 'jetpack-forms' ),
tagName: 'button',
type: 'submit',
},
],
],
Expand Down Expand Up @@ -145,11 +145,11 @@ const variations = [
],
],
[
'jetpack/button',
'core/button',
{
text: __( 'Send RSVP', 'jetpack-forms' ),
element: 'button',
lock: { remove: true },
tagName: 'button',
type: 'submit',
},
],
],
Expand Down Expand Up @@ -212,10 +212,10 @@ const variations = [
],
},
{
name: 'jetpack/button',
name: 'core/button',
attributes: {
text: __( 'Send RSVP', 'jetpack-forms' ),
element: 'button',
tagName: 'button',
lock: { remove: true },
},
},
Expand Down Expand Up @@ -298,11 +298,11 @@ const variations = [
],
],
[
'jetpack/button',
'core/button',
{
text: __( 'Send', 'jetpack-forms' ),
element: 'button',
lock: { remove: true },
tagName: 'button',
type: 'submit',
},
],
],
Expand Down Expand Up @@ -394,10 +394,10 @@ const variations = [
],
},
{
name: 'jetpack/button',
name: 'core/button',
attributes: {
text: __( 'Send', 'jetpack-forms' ),
element: 'button',
tagName: 'button',
lock: { remove: true },
},
},
Expand Down Expand Up @@ -487,11 +487,11 @@ const variations = [
],
],
[
'jetpack/button',
'core/button',
{
text: __( 'Book appointment', 'jetpack-forms' ),
element: 'button',
lock: { remove: true },
tagName: 'button',
type: 'submit',
},
],
],
Expand Down Expand Up @@ -567,10 +567,10 @@ const variations = [
],
},
{
name: 'jetpack/button',
name: 'core/button',
attributes: {
text: __( 'Book appointment', 'jetpack-forms' ),
element: 'button',
tagName: 'button',
lock: { remove: true },
},
},
Expand Down Expand Up @@ -633,11 +633,11 @@ const variations = [
],
],
[
'jetpack/button',
'core/button',
{
text: __( 'Send Feedback', 'jetpack-forms' ),
element: 'button',
lock: { remove: true },
text: __( 'Send feedback', 'jetpack-forms' ),
tagName: 'button',
type: 'submit',
},
],
],
Expand Down Expand Up @@ -683,10 +683,10 @@ const variations = [
],
},
{
name: 'jetpack/button',
name: 'core/button',
attributes: {
text: __( 'Send Feedback', 'jetpack-forms' ),
element: 'button',
tagName: 'button',
lock: { remove: true },
},
},
Expand Down Expand Up @@ -888,9 +888,9 @@ const variations = [
{ layout: { type: 'flex', justifyContent: 'right' } },
[
[
'jetpack/button',
'core/button',
{
element: 'button',
tagName: 'button',
uniqueId: 'previous-step',
customVariant: 'previous',
text: __( '← Back', 'jetpack-forms' ),
Expand All @@ -899,19 +899,19 @@ const variations = [
},
],
[
'jetpack/button',
'core/button',
{
element: 'button',
tagName: 'button',
uniqueId: 'next-step',
customVariant: 'next',
text: __( 'Next →', 'jetpack-forms' ),
metaName: __( 'Next button', 'jetpack-forms' ),
},
],
[
'jetpack/button',
'core/button',
{
element: 'button',
tagName: 'button',
uniqueId: 'submit-step',
customVariant: 'submit',
text: __( 'Submit', 'jetpack-forms' ),
Expand Down Expand Up @@ -956,11 +956,11 @@ const variations = [
[ [ 'jetpack/label' ], [ 'jetpack/input', { type: 'checkbox' } ] ],
],
[
'jetpack/button',
'core/button',
{
text: __( 'Subscribe', 'jetpack-forms' ),
element: 'button',
lock: { remove: true },
tagName: 'button',
type: 'submit',
},
],
],
Expand Down Expand Up @@ -992,10 +992,10 @@ const variations = [
],
},
{
name: 'jetpack/button',
name: 'core/button',
attributes: {
text: __( 'Subscribe', 'jetpack-forms' ),
element: 'button',
tagName: 'button',
lock: { remove: true },
},
},
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/forms/src/blocks/dropzone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const settings = {
description: __( 'A dropzone for file uploads.', 'jetpack-forms' ),
parent: [ 'jetpack/field-file' ],
allowedBlocks: [
'core/buttons',
'core/button',
'core/heading',
'core/image',
'core/list',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ export default function useFormWrapper( { attributes, clientId, name } ) {
clientId,
createBlock( FORM_BLOCK_NAME, {}, [
createBlock( name, attributes, getBlocks( clientId ) ),
createBlock( 'jetpack/button', {
createBlock( 'core/button', {
text: __( 'Submit', 'jetpack-forms' ),
element: 'button',
lock: { remove: true },
type: 'submit',
tagName: 'button',
} ),
] )
);
Expand Down
Loading
Loading