Skip to content

Forms: fix inconsistent weights in outline style and terms labels #43545

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 6 commits into
base: update/migrate-form-fields-to-inner-blocks
Choose a base branch
from

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented May 21, 2025

Fixes FORMS-41

Proposed changes:

  1. Ensure that existing font-weight CSS does not override block and global label styles by adjusting specificity of default font-weight rules. This ensures consistency in frontend and editor.
  2. Ensure the terms and condition label is consistent in frontend and editor, and is overridable by global styles (jetpack/option)

Testing instructions:

Create an outlined form block with:

  • inputs
  • multi options
  • select
  • terms
  • text area

In global styles, update the typography appearance for the jetpack/label block to bold and italic or some other conspicuous combo.

Screenshot 2025-05-21 at 3 12 52 pm

Save that. Check that the frontend and editor are consistent.

Before (editor wasn't displaying the global font weight)

Screenshot 2025-05-21 at 2 53 58 pm

After (it now does)

Screenshot 2025-05-21 at 3 12 43 pm

Now reset your global styles for the label block.

Head to the post editor and apply a typography appearance to the label.

Check that the frontend and editor are consistent.

Before

Editor Frontend
Screenshot 2025-05-21 at 3 05 09 pm Screenshot 2025-05-21 at 3 05 14 pm

After

Editor Frontend
Screenshot 2025-05-21 at 3 14 49 pm Screenshot 2025-05-21 at 3 14 45 pm

Also check that the terms and conditions label has a weight of 400 in both the frontend and editor. The frontend has always been 400.

Before

Screenshot 2025-05-21 at 3 16 16 pm

After

Screenshot 2025-05-21 at 3 16 25 pm

Copy link
Contributor

github-actions bot commented May 21, 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/forms-inner-blocks-label-font-weight-specificity branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/forms-inner-blocks-label-font-weight-specificity

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

github-actions bot commented May 21, 2025

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: We would recommend that you add a section to the PR description to specify whether this PR includes any changes to data or privacy, like so:

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

My PR adds *x* and *y*.

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

jp-launch-control bot commented May 21, 2025

Code Coverage Summary

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

Full summary · PHP report · JS report

@ramonjd ramonjd changed the title Forms: fix inconsistent weights in outline style and terms labels May 21, 2025
@ramonjd ramonjd marked this pull request as ready for review May 21, 2025 05:19
@ramonjd ramonjd self-assigned this May 21, 2025
@ramonjd ramonjd requested review from andrewserong and talldan May 21, 2025 05:19
@ramonjd ramonjd force-pushed the fix/forms-inner-blocks-label-font-weight-specificity branch from 507e24c to d364658 Compare May 22, 2025 01:13
@ramonjd ramonjd force-pushed the fix/forms-inner-blocks-label-font-weight-specificity branch from d364658 to 742cd8c Compare May 22, 2025 01:44
}


:where(.contact-form label.consent) {
Copy link
Member

Choose a reason for hiding this comment

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

I think this specificity reduction is causing font-weight: 700 to win out, along with allowing themes to accidentally cause the text to be larger than intended. In testing with TwentyTwenty this is what I'm seeing:

Trunk This PR
image image
image

Copy link
Member

Choose a reason for hiding this comment

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

I'm aware you moved the specificity back in 0791de8, though — these specificity changes sure are tricky to change! 😓

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh dang. I'm not sure what the right thing to do is here.

How much should we pay attention to the styles of every theme? I'm not sure it's a winning game.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe for the consent field it's okay to raise specificity. I think the only major result is that global styles changes to label typography will be overwritten. 🤔

Copy link
Member

@andrewserong andrewserong May 22, 2025

Choose a reason for hiding this comment

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

In this case, it's the grunion CSS that appears to be winning out and setting font-weight: 700 at least?

How much should we pay attention to the styles of every theme? I'm not sure it's a winning game.

Me either. In contrast to what we might do in core, I think Jetpack being opinionated is fine, and if themes set general rules for how labels should appear, I think that's probably okay, too.

From testing locally, I think the consent specificity can be upped back to .contact-form :where(label.consent) as setting the font-weight in global styles winds up being output as :root :where(.wp-block-jetpack-option) { which seems to win out?

image

So in this case, I think global styles rules still work okay with slightly upped specificity, but I very well might be missing something in my testing!

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for testing that!

Copy link
Member Author

Choose a reason for hiding this comment

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

By Jove, you're right!

Global styles looking good. Here's me updating the option block font appearance:

Editor Frontend
Screenshot 2025-05-22 at 3 43 57 pm Screenshot 2025-05-22 at 3 44 00 pm

Both are 400 otherwise 👍🏻

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in c875ed7

Copy link
Member

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

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

All testing well for me, now! Might be worth double checking that this doesn't conflict with @talldan's specificity work, but otherwise looks good to merge in to me 👍

@talldan
Copy link
Contributor

talldan commented May 22, 2025

Might be worth double checking that this doesn't conflict with @talldan's specificity work, but otherwise looks good to merge in to me 👍

Yep, I'm reviewing now if you can hold off merging. At a first glance a lot of these selectors seem too high/low specificity.

0-1-0 should be the rule of thumb.

font-weight: 400;
}
.jetpack-field-consent,
.jetpack-field-checkbox .jetpack-field-label .jetpack-field-label__input {
Copy link
Contributor

@talldan talldan May 22, 2025

Choose a reason for hiding this comment

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

From what I can tell this selector isn't doing anything. I guess it's the same selector that was used in trunk, but what I'm not sure about is if it's working in trunk due to the different markup.

It's very high specificity, so if it did work it'd probably break global styles. 😅

I think we can either remove it, or fix it and change it to 0-1-0 specificity

Copy link
Contributor

Choose a reason for hiding this comment

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

Just for clarification, it's the .jetpack-field-checkbox .jetpack-field-label .jetpack-field-label__input one that I'm referring to.

@@ -1065,6 +1066,10 @@
font-weight: 700;
}

:where(.is-style-outlined .wp-block-jetpack-label) {
Copy link
Contributor

@talldan talldan May 22, 2025

Choose a reason for hiding this comment

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

This is making the specificity 0-0-0. Elsewhere we're using 0-1-0 specificity for these kind of styles, the rationale being that we want to override css resets which are often 0-0-1, but still stay low enough for global styles and block styles so that they can override.

Hard to say if a theme would change the label font size, but I think a small bump in specificity is safest.

Comment on lines 93 to 94
:where( .grunion-checkbox-multiple-options legend ),
:where( .grunion-radio-options legend ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the rationale for reducing to zero? In general I think it should also be aiming for 0-1-0 for consistency, otherwise themes have a hard time working around it.

Copy link
Member Author

Choose a reason for hiding this comment

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

No rationale. I'm playing Whac-A-Mole. 😄

0-1-0 for consistency

I'll fix this, thanks for confirming!

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) [Feature] Contact Form [Package] Forms [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants