-
Notifications
You must be signed in to change notification settings - Fork 841
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?
Changes from all commits
34550d4
172eb2d
610fa48
0cc1193
1e4c34f
6215753
c6b007f
82764ad
f795505
b11a368
f382e5f
708017b
9ebe215
90f3322
1d0a3c2
2b71316
df87d1f
7e6d324
caa35c7
add6cad
0678483
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,17 +54,20 @@ | |
| flex: 1 1 100%; | ||
| } | ||
|
|
||
| // .wp-block:not(.wp-block-buttons):not(.wp-block-button) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just noting that the line needs removing before merging. |
||
| .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); | ||
|
|
@@ -86,6 +89,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%; | ||
|
|
@@ -96,16 +100,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; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1069,7 +1069,7 @@ class='{$container_classes_string}' | |
| * @param int $id Contact Form ID. | ||
| */ | ||
| $url = apply_filters( 'grunion_contact_form_form_action', $url, $GLOBALS['post'], $id, $page ); | ||
| $has_submit_button_block = str_contains( $content, 'wp-block-jetpack-button' ); | ||
| $has_submit_button_block = str_contains( $content, 'wp-block-jetpack-button' ) || str_contains( $content, 'wp-block-button' ); | ||
| $form_classes = 'contact-form commentsblock'; | ||
| if ( $submission_success ) { | ||
| $form_classes .= ' submission-success'; | ||
|
|
@@ -1104,8 +1104,11 @@ class='" . esc_attr( $form_classes ) . "' $form_aria_label | |
| $r = preg_replace( '/<div class="wp-block-jetpack-form-step-navigation__wrapper/', self::render_error_wrapper() . ' <div class="wp-block-jetpack-form-step-navigation__wrapper', $r, 1 ); | ||
| } 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. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| $r = preg_replace( '/<div class="wp-block-jetpack-button/', self::render_error_wrapper() . ' <div class="wp-block-jetpack-button', $r, 1 ); | ||
| if ( str_contains( $r, 'wp-block-buttons' ) ) { | ||
| $r = preg_replace( '/<div class="wp-block-buttons/', self::render_error_wrapper() . ' <div class="wp-block-buttons', $r, 1 ); | ||
| } | ||
| } | ||
|
|
||
| // In new versions of the contact form block the button is an inner block | ||
|
|
||
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?