Skip to content

Forms: Fix outline style label font size #43590

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

Open
wants to merge 8 commits into
base: update/migrate-form-fields-to-inner-blocks
Choose a base branch
from

Conversation

talldan
Copy link
Contributor

@talldan talldan commented May 23, 2025

Fixes and issue I noticed while working on JETPACK-277

Note - this merges into #42890 rather than trunk.

Proposed changes:

If a user creates a form and uses the Outlined form style variation, they can no longer adjust the global styles font size of labels for any inputs that are focused, have a placeholder, or if the field is a Single/Multi choice field. This only happens in #42890, in trunk it works fine.

The issue is that we're attempting to use a font-size: 0.8em to scale the font to a smaller size when a field is focused, but this rule completely overrides the font-size applied by global styles. Block styles can also override the 0.8em, so have the opposite effect.

The fix I've taken is to move the font-size: 0.8em rule to a child element, so it correctly scales the inherited font size from any global/block styles that are set on the parent. In the editor there's already a child element that can serve this purpose. On the frontend, there is no element, so a new span has been added. This might be a good idea anyway, as it makes the markup more like the editor, although it's not an exact match.

As part of this, the PR also updates the scaling of the required text, which is usually 85% of the size of the label so that it works consistently.

With the font size moved to a different element, a new transition also has to be implemented for the font-size scaling, otherwise it looks jarring when clicking into or out of a field.

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

p1747968046579529-slack-C02A76B714Z

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

No

Testing instructions:

  1. Add a contact form
  2. With the form selected, change to the 'Outlined' style variation in the block inspector
  3. Select one of the inputs and type some placeholder text in
  4. Go to Global Styles > Blocks > Label and change the font size to something noticabely different (e.g. XL or XXL)

Expected: The font size should visible change:
Screenshot 2025-05-23 at 3 53 44 pm

Before: The font size stayed the same:
Screenshot 2025-05-23 at 4 06 24 pm

@talldan talldan requested review from ramonjd and andrewserong May 23, 2025 08:08
@talldan talldan self-assigned this May 23, 2025
@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 May 23, 2025
Copy link
Contributor

github-actions bot commented May 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/outline-style-label-font-size branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/outline-style-label-font-size

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

@@ -809,7 +810,6 @@
position: relative;
top: 50%;
transform: translateY(-50%);
will-change: transform;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For most fields, transform actually doesn't change it stays at transform: translateY(-50%);, so I've removed this.

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

Code Coverage Summary

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

Full summary · PHP report · JS report

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 [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [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.

1 participant