Skip to content

[WIP] Forms: Fix Outlined form style for inner block based fields JETPACK-273 #43202

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

Conversation

aaronrobertshaw
Copy link
Contributor

JETPACK-273

Proposed changes:

  • Updates the Input block's selector to target the notched label wrappers for the outlined block style borders

Note: This PR only looks at the Global Styles side of borders for inner block based fields. It is incomplete.

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:

  • Go to '..'

aaronrobertshaw and others added 30 commits April 22, 2025 14:19
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.
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.
Updates legacy form field blocks to use shared inner blocks:
- jetpack/input
- jetpack/label
- jetpack/option
- jetpack/options

This commit also updates the registration of form blocks so the new
shared blocks are available in the editor.
Co-authored-by: Ramon <[email protected]>
* Refactor and update form field syncing.

- Use a parent react context provider as the source of truth instead of an
arbitrary sibling block.
- Perform a deep equality check before syncing to prevent against spurious
updates.

* When updating the block own attributes, mark the change as not persistent so that the user can undo

* Prime the previousOwnAttributes value so that we avoid updating syncedAttributes unnecessarily

* Update inline docs

* Prime the synced attributes when they are initially unset

* Fix syncing of styles across checkbox and consent options

---------

Co-authored-by: Aaron Robertshaw <[email protected]>
…43027)

* Forms: Fix error thrown in previews for synced form fields

* Clean up

* Rename the context type stuff
…ne 'class' attribute on the extra_attrs array
aaronrobertshaw and others added 13 commits April 22, 2025 14:29
* Enhance unit tests for Contact_Form_Block by adding support checks

This commit updates the `test_register_child_blocks` method to include an optional parameter for expected block supports and introduces a new test method, `test_child_blocks_block_supports`, to verify the configuration of block supports for various Jetpack blocks. The data provider for the new test method is also added, ensuring comprehensive testing of block support attributes.

* Add unit test for gutenblock_render_field_radio method

This commit introduces a new test method, `test_gutenblock_gutenblock_render_field_radio`, to validate the rendering of the radio field block in the Contact Form Plugin. The test checks that the generated shortcode matches the expected output, ensuring proper functionality of the radio field block with various attributes and inner blocks.

* changelog

* remove duplicate tests. silly me!

* Apply suggestions from code review

Co-authored-by: Aaron Robertshaw <[email protected]>

* syncing server block supports with frontend

* try again

---------

Co-authored-by: Aaron Robertshaw <[email protected]>
* Ensure jetpack-field__input classname applies to date picker input instead of jetpack-field__date

* Remove explicit date type in appointment form variation

* Specify the field type for the date field in the block template

* Iron out inconsistency of date type for date picker inputs

* Tied up text fields array

---------

Co-authored-by: Aaron Robertshaw <[email protected]>
This reverts commit 38791a8.

Restoring these in case they were in place for coverage requirements.
* Hoist @cover annotations to class level.

* changelog
* Fix field block examples being altered by useFormWrapper

useFormWrapper adds a form wrapper around any field that doesn't have one.

It wasn't preserving the field's own inner blocks, which became visible in the block
examples, where single or multiple choice fields have inner blocks but no wrapper.

This PR ensures the inner blocks are preserved by calling getBlocks to get the inner
blocks of the field and passing that as the inner blocks in the replaceBlocks call
within useFormWrapper.

* Small improvement to variable name

* Add missing useEffect deps

* Fix select/dropdown example

* Switch e2e test close welcome guide code to use preferences
- Ensure block class is added to legend element
- Add custom block classes and styles to legend
- Tweak default style specificity so global styles can apply
Copy link
Contributor

github-actions bot commented Apr 23, 2025

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 fix/outlined-form-global-styles-for-inner-blocks branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/outlined-form-global-styles-for-inner-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

Copy link
Contributor

github-actions bot commented Apr 23, 2025

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 🤖


🔴 Action required: Please add missing changelog entries for the following projects: projects/packages/forms

Use the Jetpack CLI tool to generate changelog entries by running the following command: jetpack changelog add.
Guidelines: /docs/writing-a-good-changelog-entry.md


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!

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Apr 23, 2025
Copy link

Code Coverage Summary

No summary data is available for parent commit c5ee076, so cannot calculate coverage changes. 😴

If that commit is a feature branch rather than a trunk commit, this is expected. Otherwise, this should be updated once coverage for c5ee076 is available.

Full summary · PHP report · JS report

@andrewserong andrewserong force-pushed the update/migrate-form-fields-to-inner-blocks branch from c543a51 to 793a2a9 Compare April 28, 2025 00:02
@ramonjd
Copy link
Member

ramonjd commented May 1, 2025

@ramonjd ramonjd closed this May 1, 2025
@ramonjd ramonjd deleted the fix/outlined-form-global-styles-for-inner-blocks branch May 1, 2025 07:56
@github-actions github-actions bot removed [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants