Skip to content

Commit 4da51e3

Browse files
CGastrellmatticbot
authored andcommitted
Forms: Set consent block to not required when using implicit mode (#46443)
* changelog * exclude implicit consent blocks from required watcher * change consent block to force not required on implicit mode * fix wrong attribute check * add required setting for terms consent field * add required block controls for terms consent field. Extend toolbar functionality to disable the button and provide an explanation for being disabled Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/20956327835 Upstream-Ref: Automattic/jetpack@28959d2
1 parent 72e6525 commit 4da51e3

File tree

9 files changed

+152
-145
lines changed

9 files changed

+152
-145
lines changed

jetpack_vendor/automattic/jetpack-forms/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ This is an alpha version! The changes listed here are not final.
1717
- Update package dependencies.
1818

1919
### Fixed
20+
- Consent block: automatically set required to false when consent type is implicit
2021
- Forms: fix dashboard routing on wpcom.
2122

2223
## [7.3.0] - 2026-01-12
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('jetpack-connection', 'jetpack-script-data', 'lodash', 'react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-jp-i18n-loader', 'wp-notices', 'wp-plugins', 'wp-polyfill', 'wp-primitives', 'wp-url'), 'version' => '2833638571620141c23e');
1+
<?php return array('dependencies' => array('jetpack-connection', 'jetpack-script-data', 'lodash', 'react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-jp-i18n-loader', 'wp-notices', 'wp-plugins', 'wp-polyfill', 'wp-primitives', 'wp-url'), 'version' => 'a6321396bb8add9aa94d');

jetpack_vendor/automattic/jetpack-forms/dist/blocks/editor.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jetpack_vendor/automattic/jetpack-forms/src/blocks/contact-form/edit.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,12 @@ const isInputWithRequiredField = ( fullName?: string ): boolean => {
110110
// TS is inferring the type wrong. Fix is to update childBlocks to TS with types.
111111
const hasRequired = field && field?.settings?.attributes?.required !== undefined;
112112
const isHidden = field?.name === 'field-hidden';
113-
return hasRequired && ! isHidden;
113+
const isImplicitConsent =
114+
field?.name === 'field-consent' &&
115+
// @ts-expect-error: childBlocks are defined in JS without explicit types.
116+
// TS is inferring the type wrong. Fix is to update childBlocks to TS with types.
117+
field?.settings?.attributes?.consentType !== 'explicit';
118+
return hasRequired && ! isHidden && ! isImplicitConsent;
114119
};
115120

116121
type CustomThankyouType =

jetpack_vendor/automattic/jetpack-forms/src/contact-form/class-contact-form-field.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,19 +1412,20 @@ private function render_consent_field( $id, $class ) {
14121412
$consent_message = 'explicit' === $consent_type ? $this->get_attribute( 'explicitconsentmessage' ) : $this->get_attribute( 'implicitconsentmessage' );
14131413
$label_class = 'grunion-field-label consent consent-' . esc_attr( $consent_type );
14141414
$label_class .= $this->option_classes ? ' ' . $this->option_classes : '';
1415+
$label_class .= $this->is_error() ? ' form-error' : '';
14151416
$has_inner_block_option_styles = ! empty( $this->get_attribute( 'optionstyles' ) );
14161417

14171418
$field = "<label class='" . esc_attr( $label_class ) . "' style='" . esc_attr( $this->label_styles ) . ( $has_inner_block_option_styles ? esc_attr( $this->option_styles ) : '' ) . "'>";
14181419

14191420
if ( 'implicit' === $consent_type ) {
14201421
$field .= "\t\t<input type='hidden' name='" . esc_attr( $id ) . "' value='" . esc_attr__( 'Yes', 'jetpack-forms' ) . "' /> \n";
14211422
} else {
1422-
$field .= "\t\t<input type='checkbox' name='" . esc_attr( $id ) . "' value='" . esc_attr__( 'Yes', 'jetpack-forms' ) . "' " . $class . "/> \n";
1423+
$field .= "\t\t<input type='checkbox' data-wp-on--change='actions.onFieldChange' name='" . esc_attr( $id ) . "' value='" . esc_attr__( 'Yes', 'jetpack-forms' ) . "' " . $class . "/> \n";
14231424
}
14241425
$field .= "\t\t" . wp_kses_post( $consent_message );
14251426
$field .= "</label>\n";
14261427
$field .= "<div class='clear-form'></div>\n";
1427-
return $field;
1428+
return $field . $this->get_error_div( $id, 'checkbox' );
14281429
}
14291430

14301431
/**

jetpack_vendor/i18n-map.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
),
6767
'jetpack-forms' => array(
6868
'path' => 'jetpack_vendor/automattic/jetpack-forms',
69-
'ver' => '7.4.0-alpha1768248146',
69+
'ver' => '7.4.0-alpha1768306492',
7070
),
7171
'jetpack-image-cdn' => array(
7272
'path' => 'jetpack_vendor/automattic/jetpack-image-cdn',

0 commit comments

Comments
 (0)