Forms: fix file upload field collapsing to content width on the front end#49978
Forms: fix file upload field collapsing to content width on the front end#49978enejb wants to merge 3 commits into
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! |
Code Coverage SummaryCoverage changed in 1 file.
|
There was a problem hiding this comment.
Pull request overview
This PR fixes the Forms File upload field rendering on the front end so it no longer collapses to its content width, by aligning its PHP render output with the other gutenblock_render_field_* implementations.
Changes:
- Remove the redundant wrapper element from
gutenblock_render_field_file()so the field’s native wrapper (.grunion-field-wrap) remains the form’s direct flex child. - Add a Forms package changelog entry describing the user-facing fix.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
projects/packages/forms/src/contact-form/class-contact-form-plugin.php |
Removes an extra wrapper around the file field render output to restore expected flex/width behavior on the front end. |
projects/packages/forms/changelog/fix-forms-file-upload-field-collapses-on-frontend |
Documents the user-facing fix in the Forms changelog (needs a small convention/wording tweak per comment). |
| public static function gutenblock_render_field_file( $atts, $content, $block ) { | ||
| $atts = self::block_attributes_to_shortcode_attributes( $atts, 'file', $block ); | ||
| // Create wrapper div for the file field | ||
| $output = '<div class="jetpack-form-file-field">'; | ||
|
|
||
| // Render the file field | ||
| $output .= Contact_Form::parse_contact_field( $atts, $content ); | ||
|
|
||
| $output .= '</div>'; | ||
|
|
||
| return $output; | ||
| return Contact_Form::parse_contact_field( $atts, $content ); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Proposed changes
gutenblock_render_field_file()wrapped the field output in an extra<div class="jetpack-form-file-field">. That wrapper — rather than the field's own.grunion-field-wrapshell — became the contact form's direct flex child. The form is a flex column withalign-items: flex-start, and the wrapper carries no width/flex rules, so it shrank to the dropzone's content width. The field-width attribute (25/50/75/100%) and horizontal form layouts both rely on those rules landing on.grunion-field-wrap.gutenblock_render_field_*method (this is how the field was originally scaffolded). With the redundant wrapper gone,.grunion-field-wrapis once again the form's direct flex child, so the field fills the form and respects width + orientation — with no new CSS.Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
Before / After (captured live on Jurassic Ninja)