Skip to content

[WIP] Forms: Create new base blocks to enable Global Styles support JETPACK-261 - #42889

Closed
aaronrobertshaw wants to merge 6 commits into
trunkfrom
add/new-form-field-blocks
Closed

aaronrobertshaw wants to merge 6 commits into
trunkfrom
add/new-form-field-blocks

Conversation

@aaronrobertshaw

@aaronrobertshaw aaronrobertshaw commented Apr 3, 2025 •

Copy link
Copy Markdown
Contributor

JETPACK-261

Fixes #42355

⚠️ Please note: This PR forms the basis for migrating form fields to inner blocks. It should not be merged until the related PR migrating to these new blocks proves they are sufficiently complete. ⚠️

Proposed changes:

  • Add news blocks for greater control over styling forms and to support global styles
  • New blocks include:
    • jetpack/input
    • jetpack/label
    • jetpack/option
    • jetpack/options

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

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

Testing instructions:

TBA

@aaronrobertshaw aaronrobertshaw added Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Feature] Forms [Status] In Progress [Block] Form Form block (also see Form package label) Triaged [Package] Forms [Feature] Forms Blocks Blocks designed to streamline user input and engagement, such as contact, newsletter sign-ups, etc. labels Apr 3, 2025
@aaronrobertshaw aaronrobertshaw self-assigned this Apr 3, 2025
@aaronrobertshaw
aaronrobertshaw marked this pull request as draft April 3, 2025 10:27
@github-actions

github-actions Bot commented Apr 3, 2025 •

Copy link
Copy Markdown
Contributor

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), and enable the add/new-form-field-blocks branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/new-form-field-blocks

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

@github-actions github-actions Bot added the [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ label Apr 3, 2025
@github-actions

github-actions Bot commented Apr 3, 2025 •

Copy link
Copy Markdown
Contributor

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:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: May 6, 2025
    • Code freeze: May 5, 2025

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

@aaronrobertshaw aaronrobertshaw changed the title [WIP] Forms: Create new base blocks to enable Global Styles support [WIP] Forms: Create new base blocks to enable Global Styles support JETPACK-261 Apr 3, 2025
@jp-launch-control

jp-launch-control Bot commented Apr 3, 2025 •

Copy link
Copy Markdown

Code Coverage Summary

17 files are newly checked for coverage. Only the first 5 are listed here.

File Coverage
projects/packages/forms/src/blocks/input/edit.js 0/23 (0.00%) 💔
projects/packages/forms/src/blocks/input/index.js 0/2 (0.00%) 💔
projects/packages/forms/src/blocks/input/save.js 0/1 (0.00%) 💔
projects/packages/forms/src/blocks/label/edit.js 0/18 (0.00%) 💔
projects/packages/forms/src/blocks/label/index.js 0/2 (0.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.

@aaronrobertshaw
aaronrobertshaw force-pushed the add/new-form-field-blocks branch from 1ce694a to 9bcd54d Compare April 6, 2025 23:36
Introduces foundational form field blocks:
- jetpack/input
- jetpack/label
- jetpack/option
- jetpack/options

These blocks will be reused across all field types using inner blocks.
- Prevents adding bulk changes when syncing blocks to the undo stack
- Correctly determines the parent field block for option blocks to check
  if syncing is enabled
- Correctly find all option blocks regardless of whether they are a
  field's direct child, e.g. consent, or nested within an options block
  e.g. single/multiple choice fields.
@aaronrobertshaw
aaronrobertshaw force-pushed the add/new-form-field-blocks branch from 2171100 to dd0c310 Compare April 7, 2025 23:29
Comment on lines +48 to +61
// TODO: Work out the best approach here for type.
// Currently, the type attribute isn't required as it can be passed via block
// context. It turns out though that choice items for the single and multiple
// choice fields had custom and different icons. Sharing a single
// `jetpack/option` block for global styling purposes means that can't happen
// without block variations. Block variations would require the type attribute
// at this block's level to allow different icons for each variation.
//
// Is this really needed?
//
// type: {
// type: 'string',
// default: 'checkbox',
// },

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this just about different icons within the editor? If that's the only difference between the two, then I'd lean toward not including a type attribute for now, and circle back to it if we wind up feeling like there's a need for it further down the track.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is.

This came up in discussion with @simison and the expectation is we might ideally have separate icons. The catch is we'll need to refactor this attribute sooner rather than later to avoid needing deprecations if we waited until post-release of inner blocks.

This is an enhancement over trunk however the is some work required to
make this actually work, especially given the shortcode rendering on the
frontend. For the time being this support will explicitly be opted out
of. It can be revisited when the benefit justifies the additional
complexity and work.
@aaronrobertshaw

Copy link
Copy Markdown
Contributor Author

With many hands working on testing and refining #42890, it's proven tricky to ensure this base branch is kept up-to-date with all the tweaks to the new base blocks without interfering with progress and momentum on #42890.

After some discussion with @talldan, I've decided to close this PR so we only have a single PR to manage with #42890 now to be based off trunk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Form Form block (also see Form package label) Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Feature] Forms Blocks Blocks designed to streamline user input and engagement, such as contact, newsletter sign-ups, etc. [Feature] Forms [Package] Forms [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ Triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Forms: Create new form field inner blocks (Label, Input, Option, etc.)

2 participants