-
Notifications
You must be signed in to change notification settings - Fork 820
[WIP] Forms: Try using inner blocks for file upload field #42980
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
[WIP] Forms: Try using inner blocks for file upload field #42980
Conversation
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.
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.
Note: This commit does not address updating the frontend rendering to include the correct block classes and inline styles from block supports.
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 🤖 🔴 Action required: Please add missing changelog entries for the following projects: Use the Jetpack CLI tool to generate changelog entries by running the following command: Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCannot generate coverage summary while tests are failing. 🤐 Please fix the tests, or re-run the Code coverage job if it was something being flaky. |
{ | ||
url: DEFAULT_ICON, | ||
width: 24, | ||
height: 24, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The addition of these width / height attributes seems to be creating an issue. When I first insert the block it loads as expected. I can see the width/height attributes set correctly to 24 px on the sidebar. If I save and check the frontend, the block loads as expected.
But... if I just refresh the editor, I get a block validation error. Here's the error:
blocks.js?ver=e851ee8e9644a9abf7ed:11967 Block validation: Block validation failed for `core/image` ({name: 'core/image', icon: {…}, keywords: Array(7), attributes: {…}, providesContext: {…}, …}).
Content generated by `save` function:
<figure class="wp-block-image aligncenter is-resized is-style-default" style="margin-bottom:20px"><img src="https://erick2.jurassic.tube/wp-content/plugins/jetpack/jetpack_vendor/automattic/jetpack-forms/assets/images/upload-icon.svg" alt=""/></figure>
Content retrieved from post body:
<figure class="wp-block-image aligncenter is-resized is-style-default" style="margin-bottom:20px"><img src="https://erick2.jurassic.tube/wp-content/plugins/jetpack/jetpack_vendor/automattic/jetpack-forms/assets/images/upload-icon.svg" alt="" style="width:24px;height:24px"/></figure>
In short, the save function content does not contain the style tag with width/height.
0da45ad
to
075be3a
Compare
Rather than deal with complex merge conflicts after rebase of base branch, just moved work to #43114 Closing in favor of that PR. |
Proposed changes:
This isn't a full implementation as it doesn't update the frontend rendering of the file field to ensure the correct classes and styles are applied e.g. the default block class and block supports.
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions: