Skip to content

Conversation

@enejb
Copy link
Member

@enejb enejb commented Jan 5, 2026

This PR is part of #46297
It breaks up the larger PR (#46297 ) in a meaningfully smaller PR that can be reviewed easier and merged.

It adds a new Form Editor
Screenshot 2026-01-05 at 1 37 17 PM

Proposed changes:

  • Main: Now when you visit /wp-admin/post-new.php?post_type=jetpack_form you get a more tailored experience.
  • Hide the post title in the jetpack form editor.
  • Implement the locking of the form and form insertion.
  • Hide the Editor tabs when the form block is selected.
  • Autoselect the from block when no block is selected.
  • We generate the new js and css files for the jetpack form editor.
  • They are loaded in all block editors but only if you have the feature flag enabled.
  • Fixed the template so that we get the default placeholders.
  • Implement nicer block selection with the jetpack form blocks at the top of the block inserter that you find on the left side.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

No

Does this pull request change what data or activity we track or use?

No

Testing instructions:

Since we are adding a new class. You will need to run jetpack install -r after you switch to this PR.

Have the feature flag enabled in your sandbox.

add_filter( 'jetpack_block_editor_feature_flags', 'eb_register_feature' );

function eb_register_feature( $flags ) {
    $flags['reusable-forms'] = true;
    $flags['central-form-management'] = true;
    return $flags;
}

Notice that the you can visit /wp-admin/post-new.php?post_type=jetpack_form and that see the placeholder.
You should be able to save the form and add new form fields.

With the feature flag disabled.
You should not be able to visit /wp-admin/post-new.php?post_type=jetpack_form
Nothing should crash.
You can insert a form without any issues.
No form-editor js or css should be loaded.

@enejb enejb requested review from a team and Copilot January 5, 2026 21:37
@enejb enejb added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] Needs Review This PR is ready for review. [Package] Forms labels Jan 5, 2026
@github-actions github-actions bot added [Block] Contact Form Form block (also see Contact Form label) [Feature] Contact Form [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels Jan 5, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2026

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a dedicated form editor for the Jetpack Forms feature, providing a tailored editing experience when creating or editing forms via /wp-admin/post-new.php?post_type=jetpack_form. The functionality is gated behind feature flags (reusable-forms and central-form-management) and includes form locking, block nesting enforcement, and a rename command.

Key Changes

  • New form editor with automatic form block creation and locking to prevent removal/movement
  • Form rename functionality accessible via command palette when form block is selected
  • Custom styling that hides post title, editor tabs, and adjusts block appearance for form editing context

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
projects/plugins/jetpack/changelog/add-form-editor Changelog entry documenting the form editor addition
projects/packages/forms/changelog/add-form-editor Package-level changelog entry
projects/packages/forms/tools/webpack.config.form-editor.js Webpack configuration for building the form editor bundle
projects/packages/forms/src/form-editor/use-form-rename-command.tsx Custom hook providing form renaming functionality via command palette
projects/packages/forms/src/form-editor/style.scss Styling for form editor including tab hiding and rename modal
projects/packages/forms/src/form-editor/index.tsx Main form editor logic for block locking, nesting enforcement, and category management
projects/packages/forms/src/form-editor/class-form-editor.php PHP class managing allowed blocks, editor settings, and script enqueuing
projects/packages/forms/src/contact-form/class-contact-form.php Adds template definition for jetpack_form post type
projects/packages/forms/src/contact-form/class-contact-form-plugin.php Initializes Form_Editor when feature flag is enabled
projects/packages/forms/src/blocks/shared/util/constants.js Adds FORM_POST_TYPE constant for consistent reference
projects/packages/forms/src/blocks/contact-form/editor.scss Hides post title in jetpack_form editor context
projects/packages/forms/package.json Adds form-editor build tasks and required dependencies

@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2026

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the add/form-editor branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/form-editor
bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/form-editor

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@jp-launch-control
Copy link

jp-launch-control bot commented Jan 5, 2026

Code Coverage Summary

Coverage changed in 3 files.

File Coverage Δ% Δ Uncovered
projects/packages/forms/src/contact-form/class-contact-form-plugin.php 496/1459 (34.00%) -0.02% 1 ❤️‍🩹
projects/packages/forms/src/contact-form/class-contact-form.php 984/1413 (69.64%) 0.02% 0 💚
projects/packages/forms/src/blocks/shared/util/constants.js 10/10 (100.00%) 100.00% -9 💚

4 files are newly checked for coverage.

File Coverage
projects/packages/forms/src/form-editor/index.tsx 0/118 (0.00%) 💔
projects/packages/forms/src/form-editor/class-form-editor.php 56/73 (76.71%) 💚
projects/packages/forms/src/form-editor/utils/block-utils.ts 9/9 (100.00%) 💚
projects/packages/forms/src/form-editor/utils/category-utils.ts 14/14 (100.00%) 💚

Full summary · PHP report · JS report

If appropriate, add one of these labels to override the failing coverage check: Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage.

Copilot AI review requested due to automatic review settings January 5, 2026 22:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 9 comments.

Copilot AI review requested due to automatic review settings January 5, 2026 23:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 8 comments.

Copilot AI review requested due to automatic review settings January 5, 2026 23:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 19 changed files in this pull request and generated 7 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

projects/packages/forms/tests/js/form-editor/index.test.js:21

  • The second test "should have a style.scss file" doesn't actually verify anything meaningful - it just checks that true equals true. This test should either be removed or replaced with a meaningful assertion that verifies the SCSS file can be imported or that its styles are applied correctly.

Copy link
Contributor

Copilot AI commented Jan 5, 2026

@enejb I've opened a new pull request, #46446, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI review requested due to automatic review settings January 5, 2026 23:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 19 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Copilot AI review requested due to automatic review settings January 6, 2026 00:06
The form editor now tracks and restores the previous block categories order when moving the Jetpack contact form category to the front and back. Tests were added to verify tracking, restoring, and fallback behavior for category management.
Copilot AI review requested due to automatic review settings January 6, 2026 20:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 17 changed files in this pull request and generated 6 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

* @return True if the block should be locked
*/
export function shouldLockBlock( block: Block ): boolean {
const lock = block.attributes?.lock as { remove?: boolean; move?: boolean } | undefined;
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The block lock type assertion is also present in the utility file. Consider defining the BlockLock type in the block-utils.ts file and exporting it for reuse, so both the utility and the main index file can use the same type definition, improving consistency.

Copilot uses AI. Check for mistakes.
Comment on lines +430 to +443
// Expected blocks - core blocks
$expected_core_blocks = array(
'core/paragraph',
'core/heading',
'core/list',
'core/list-item',
'core/separator',
'core/spacer',
'core/columns',
'core/column',
'core/group',
'core/image',
'core/html',
);
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PHP test file includes blocks like 'core/audio', 'core/row', 'core/stack', 'core/subhead', and 'core/video' in the allowed list (lines 88-103 of the PHP file), but these blocks are not included in the test expectations (lines 430-443 in the test file). The test should verify all allowed core blocks to ensure completeness.

Copilot uses AI. Check for mistakes.
enejb added 3 commits January 6, 2026 14:46
Renamed asset files and script handles from 'jetpack-forms-editor' to 'jetpack-form-editor' for consistency. Improved TypeScript typing for block locking by introducing a BlockLock interface and updating related usages. Added asset file existence check and dynamic dependency loading in PHP registration.
Copilot AI review requested due to automatic review settings January 7, 2026 19:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 17 changed files in this pull request and generated 5 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Copilot AI review requested due to automatic review settings January 7, 2026 19:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 17 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

} else if ( categoriesFiltered ) {
categoriesFiltered = false;
moveFormsCategoryBackToOriginalOrder( previousCategories || [] );
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to 'undo' the unregisterPlugin() call? I think in most cases if you navigate to a different block editor, this should reload/reset, but I'm not 100% sure.

$screen = get_current_screen();

// Only load in block editor contexts, not site editor
if ( ! $screen || $screen->id === 'site-editor' || ! $screen->is_block_editor ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to only be loading this JS when post_type === jetpack_form? I think that's also possible with the $screen var.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my testing when I do that (limit by post type) then the switching in the block editor (clicking the edit form button) doesn't quite work as expected.

But since this feature doesn't load on the site-editor removing the script from the site editor is fine.

"type": "module",
"scripts": {
"build": "pnpm run clean && pnpm run build:blocks && pnpm run build:contact-form && pnpm run build:dashboard && pnpm run module:build",
"build": "pnpm run clean && pnpm run build:blocks && pnpm run build:contact-form && pnpm run build:dashboard && pnpm run build:form-editor && pnpm run module:build",
Copy link
Contributor

@edanzer edanzer Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@enejb - the form editor if feature flagged, but this build code will always run and include the feature flagged form editor. Same with other package.json updates below specific to the form editor.

Is that a concern?

Update: I was also trying find other places the changes might leak out of the feature flag.

  • We bump a dependency version in this file.
  • We've added tests - I assume it's fine if those run during automated testing even if functionality is feature flagged.
  • We update the template for register_post_type in a general file, but that is feature flagged upstream.

Anyways, just worth doing a sanity check that any code outside the feature flag will be safe.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for bringing this up. This will definitely create scripts even though the feature flag is not enabled.

I think this is fine since there shouldn't be an impact on the user. (They are not downloading) the script when they visit the editor. (for example) but we might be distributing the assets (js and css) files even though they the site is under the feature flag. ( but the same cases exists for PHP files)

Copy link
Contributor

@edanzer edanzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed and tested:

  • The new form editor is working well for me.
  • We removed objectionable editor hacks based on comments.
  • PHP and JS tests pass.
  • I tried to find any place our changes might leak outside the feature flag, and it mostly looks good. Added a comment/question about this elsewhere.
  • I also tested with feature flag off with no issues to confirm no regressions.

I added a few other small comments/questions.

There will be things to tweak, but I'd say let's merge so we can clear blockers and start tackling other things in smaller increments. Nice work @enejb!

@enejb enejb merged commit 125da7c into trunk Jan 7, 2026
96 of 98 checks passed
@enejb enejb deleted the add/form-editor branch January 7, 2026 22:32
@github-actions github-actions bot removed the [Status] Needs Review This PR is ready for review. label Jan 7, 2026
@github-actions github-actions bot added this to the jetpack/15.5 milestone Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Contact Form Form block (also see Contact Form label) [Feature] Contact Form [Package] Forms [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants