Skip to content

Add fallback styles for dropdown block when css vars are not populated #43101

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

talldan
Copy link
Contributor

@talldan talldan commented Apr 16, 2025

Note - this PR merges into #42890 rather than trunk.

Proposed changes:

It was noted in #43096 (review) that often when dropdown field is shown in a preview, it's missing styles.

One of the reasons this happens is explained in #41418.

I noticed there's also another contributing factor that explains why this happens for the dropdown block but not the multiline/textarea block.

The latter has fallback values set in its CSS, while the former doesn't.

In this PR I'm also setting fallbacks for the dropdown, and it seems to mostly solve the preview problems, at least in situations where the theme isn't changing the styles of the form much.

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

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

Testing instructions:

  1. Create a new post
  2. Open the inserter
  3. Search for 'Dropdown'
  4. Hover the dropdown field block to see the preview

Expected: The block should have proper border styles and padding.

Screenshots

Before

Screenshot 2025-04-16 at 5 18 22 pm

After

Screenshot 2025-04-16 at 5 18 54 pm

@talldan talldan added [Type] Bug When a feature is broken and / or not performing as intended [Feature] Contact Form [Block] Contact Form Form block (also see Contact Form label) [Package] Forms [Feature] Forms Blocks Blocks designed to streamline user input and engagement, such as contact, newsletter sign-ups, etc. Bug labels Apr 16, 2025
@talldan talldan requested review from ramonjd, andrewserong, aaronrobertshaw and a team April 16, 2025 09:21
@talldan talldan self-assigned this Apr 16, 2025
Copy link
Contributor

github-actions bot commented Apr 16, 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/dropdown-preview-styles branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/dropdown-preview-styles

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

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 16, 2025
Copy link

Code Coverage Summary

No summary data is available for parent commit a74b3db, 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 a74b3db is available.

Full summary · PHP report · JS report

Copy link
Contributor

@aaronrobertshaw aaronrobertshaw left a comment

Choose a reason for hiding this comment

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

Loving all the fixes, keep 'em coming 🚀

✅ Works for me for both field and form variation previews
✅ Couldn't break the default styling regardless of method of adding field, form variation, undo/redo, pasting etc.

LGTM 👍

@aaronrobertshaw aaronrobertshaw merged commit b056968 into update/migrate-form-fields-to-inner-blocks Apr 17, 2025
60 of 63 checks passed
@aaronrobertshaw aaronrobertshaw deleted the fix/dropdown-preview-styles branch April 17, 2025 01:20
@github-actions github-actions bot removed 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 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Contact Form Form block (also see Contact Form label) Bug [Feature] Contact Form [Feature] Forms Blocks Blocks designed to streamline user input and engagement, such as contact, newsletter sign-ups, etc. [Package] Forms [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants