Forms: allow more core blocks inside forms#47121
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
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. |
There was a problem hiding this comment.
Pull request overview
This PR enhances the Jetpack Forms block editor by allowing additional core WordPress blocks (accordion, icon, and details) to be used inside forms. The changes consolidate the allowed core blocks list between PHP and JavaScript implementations, ensuring consistency across the codebase.
Changes:
- Added
core/accordion,core/icon, andcore/detailsto the allowed blocks list in both PHP and JavaScript - Added
core/button,core/column, andcore/list-itemto JavaScript constants to match the PHP implementation - Enabled
core/iconblock in the file upload dropzone - Added corresponding changelog entries
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/packages/forms/src/form-editor/class-form-editor.php | Updated PHP allowed blocks list to include new core blocks (accordion, icon, details, etc.) |
| projects/packages/forms/src/blocks/shared/util/constants.js | Synchronized JavaScript CORE_BLOCKS constant with PHP by adding missing blocks |
| projects/packages/forms/src/blocks/dropzone/index.js | Added core/icon to the dropzone's allowed blocks |
| projects/packages/forms/changelog/allow-icon-in-dropzone | Changelog entry for dropzone icon block support |
| projects/packages/forms/changelog/add-core-blocks-to-forms | Changelog entry for consolidating allowed core blocks |
Code Coverage SummaryCoverage changed in 1 file.
|
| @@ -96,17 +95,20 @@ public static function allowed_blocks_for_jetpack_form( $allowed_block_types, $e | |||
| 'jetpack/form-progress-indicator', | |||
|
|
|||
| // Core blocks for rich content. | |||
| 'core/accordion', | |||
| 'core/audio', | |||
| 'core/button', | |||
| 'core/button', // Used for the submit button. | |||
There was a problem hiding this comment.
The inline comments about which block is used for the submit button are misleading/inconsistent. The form editor still programmatically creates a jetpack/button submit button (see projects/packages/forms/src/form-editor/index.tsx), while this list claims core/button is used for submit and jetpack/button was only used previously. Consider rewording these comments to reflect that both jetpack/button (legacy) and core/button (current) may exist for backwards compatibility, or remove the submit-button-specific wording altogether.
There was a problem hiding this comment.
@enejb, can you check if the above is true, and we need to update it to use the core button instead if it is.
(Let's keep the comment as-is.)
| // Core blocks for rich content. | ||
| 'core/accordion', | ||
| 'core/audio', | ||
| 'core/button', | ||
| 'core/button', // Used for the submit button. | ||
| 'core/code', |
There was a problem hiding this comment.
The allowed core block list for the form CPT was expanded here, but the existing PHPUnit coverage for Form_Editor::allowed_blocks_for_jetpack_form() doesn’t assert any of these newly-allowed blocks. Please update projects/packages/forms/tests/php/form-editor/Form_Editor_Test.php::test_allowed_blocks_for_jetpack_form_restricts_blocks to include assertions for core/accordion, core/details, and core/icon so future regressions are caught.
There was a problem hiding this comment.
This comment is legit and low effort.
vianasw
left a comment
There was a problem hiding this comment.
Works. It would be nice to also update the list in the tests for allowed_blocks_for_jetpack_form.
Synchronize the allowed core blocks lists in both JavaScript (constants.js) and PHP (Form_Editor class) by adding: - core/accordion, core/icon, core/details (new additions) - core/button, core/column, core/list-item (for consistency) This ensures both the block editor and server-side filtering allow the same set of core blocks inside forms. Co-authored-by: Cursor <cursoragent@cursor.com>
Enable the core/icon block to be added inside the dropzone block, allowing users to customize the file upload UI with icons. Co-authored-by: Cursor <cursoragent@cursor.com>
- sort - remove duplicate button - comment on buttons
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
d73fc7b to
9d1b282
Compare
Proposed changes:
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
The icon block was just added (WordPress/gutenberg#71227) to Gutenberg in preparation to be included in WP 7.0, so you might need to run the latest
trunkand enable a couple of experiments to see it:Test icon block inside file upload field.
You can just find the accordion and details blocks in the block inserter normally. Try adding fields inside them.