Skip to content

Forms: fix file upload field collapsing to content width on the front end#49978

Open
enejb wants to merge 3 commits into
trunkfrom
fix/forms-file-upload-field-collapses-on-frontend
Open

Forms: fix file upload field collapsing to content width on the front end#49978
enejb wants to merge 3 commits into
trunkfrom
fix/forms-file-upload-field-collapses-on-frontend

Conversation

@enejb

@enejb enejb commented Jun 25, 2026

Copy link
Copy Markdown
Member

Proposed changes

  • The Forms File upload field collapsed to its content width on the front end instead of filling the form like every other field — and unlike how it renders in the block editor.
  • Root cause: 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-wrap shell — became the contact form's direct flex child. The form is a flex column with align-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.
  • Fix: return the field directly, exactly like every other gutenblock_render_field_* method (this is how the field was originally scaffolded). With the redundant wrapper gone, .grunion-field-wrap is 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

  • Create a Form with a File upload field (or use a page that already has one).
  • View the form on the front end.
  • Before: the file upload dropzone is noticeably narrower than the Name/Email/Message fields. After: it spans the full form width, matching the editor.
  • For good measure, set the file field's width to 50%/75% and/or switch the form to a horizontal layout — the file field should now size like the other fields.

Before / After (captured live on Jurassic Ninja)

Before After
before after

@github-actions

github-actions Bot commented Jun 25, 2026

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 fix/forms-file-upload-field-collapses-on-frontend branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/forms-file-upload-field-collapses-on-frontend

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 commented Jun 25, 2026

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 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!

@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 Jun 25, 2026
@jp-launch-control

jp-launch-control Bot commented Jun 25, 2026

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/forms/src/contact-form/class-contact-form-plugin.php 699/1553 (45.01%) 0.41% -8 💚

Full summary · PHP report · JS report

@enejb enejb marked this pull request as ready for review June 25, 2026 21:32
@enejb enejb requested review from CGastrell and Copilot June 25, 2026 21:32
@enejb enejb added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Status] In Progress labels Jun 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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).

Comment on lines 1372 to +1374
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 );
enejb and others added 2 commits June 25, 2026 14:36
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@dhasilva dhasilva left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Nice!

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.

3 participants