Forms: Scale checkbox input with custom font sizes (FORMS-682)#48538
Forms: Scale checkbox input with custom font sizes (FORMS-682)#48538alinclamba wants to merge 1 commit intotrunkfrom
Conversation
Anchor the SCSS rule that gives the checkbox input `font-size: inherit` to the field's own wrapper class (`grunion-field-checkbox-wrap`) instead of `.is-style-list`. The latter never serialized to post content for singular Checkbox (set inside `__unstableMarkNextChangeAsNotPersistent` in `field-checkbox/edit.js`), so the selector never matched in the rendered DOM and the input kept the browser-default font size. The same selector group covers singular Consent; in normal usage its className gets flushed by subsequent `setAttributes` calls and the bug rarely surfaces there, but the fix removes that fragility too.
|
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 SummaryThis PR did not change code coverage! That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷 |
|
Ran |
Fixes #42446 | Part of pfln9p-2BB-p2 | FORMS-682 |
Proposed changes
.is-style-listto the field's own wrapper class (grunion-field-checkbox-wrapandgrunion-field-consent-wrap). The new selectors target a class that's unconditionally emitted in the rendered HTML, so the rule reliably matches and the input getsfont-size: inherit. Without the fix, the input keeps the browser-default font size when a custom font size is set.projects/packages/forms/src/contact-form/css/grunion.scss. Same selector count, same specificity (0,2,1), no PHP changes.Root cause
The SCSS rule that gives
input.checkboxitsfont-size: inherit(so itswidth: 1emresolves against the parent's font-size) is anchored on an.is-style-listancestor. For Checkbox-Multiple and Radio that class is reliably saved, because they have a registered block style withis_default => true. For singular Checkbox, the equivalent class is set infield-checkbox/edit.jsviasetAttributesinside a__unstableMarkNextChangeAsNotPersistent()block, which prevents that next change from being serialized. Because users typically only edit the inner Option block's label after insertion — not the field-checkbox block itself — no subsequentsetAttributesever flushes the queued className, andis-style-listnever reaches the saved post content. The class shows up in the editor but not in the rendered frontend HTML; the SCSS rule never matches; the input falls back to the browser-default font size.Preset values (XXL, XL, L, M, S) escape the bug because the preset class (e.g.
has-xx-large-font-size) is appended to the input's ownclassattribute viaContact_Form_Field::render()and resolved by WordPress' global preset CSS — independent of inheritance. Custom values produce only an inline style on the wrapper and label, which the input can't reach withoutfont-size: inherit, so the bug only surfaces with custom values.Side-effect: Consent
The singular Consent field shares the same SCSS selector groups in all four affected spots, and has the same
__unstableMarkNextChangeAsNotPersistentpattern in its edit.js. In normal usage Consent escapes the bug, because users almost always trigger a subsequentsetAttributeson the consent block (toggling Implicit/Explicit, editing the message, etc.) which flushes the queuedis-style-listinto saved post content — so the existing CSS selector matched. Consent's bug only surfaces if a user manually removesis-style-listfrom the block's Advanced CSS Classes, or otherwise prevents the className from persisting.Even though the practical impact for Consent is small, the fix removes the fragility: the new selector anchors on a class that's unconditionally present in the rendered output, so Consent works regardless of how the block was edited. The change to Consent and the change to Checkbox are structurally one change — splitting the SCSS selector groups to fix only Checkbox would add lines and create an asymmetry that doesn't exist today.
Considered alternatives
is-style-listblock style for the singular Checkbox and Consent blocks. Rejected: it would fix new posts only — existing saved posts (without the className serialized) would stay broken.option_stylesdirectly on the input element fromrender_checkbox_field()PHP. Rejected: broader change for the same outcome; the CSS selector swap delivers it in one motion.Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
Tested on a clean Jurassic Ninja sandbox (Twenty Twenty-Four, Jetpack 15.8-beta, only Jetpack + Akismet active), Chrome.
To reproduce the bug on
trunk:4.5rem) via the slider in the Block Inspector.To verify the fix:
font-size: should be the resolved clamp value (~45px for4.5rem), not 13.333px.Cases verified:
is-style-listfrom the Advanced CSS Classes panel — see "Side-effect: Consent" above.pnpm jetpack test php packages/formspasses (CSS-only fix, no PHP test changes expected).Coverage gaps for transparency:
font-size: inheritresolving against the wrapper's clamp value, which is browser-agnostic in behavior, so the missed coverage is unlikely to surface a different result. Happy to add Safari verification before merge if a reviewer asks.Visual A/B
Singular Checkbox + custom 4.5rem (Row 3 in my testing)
Before fix:

After fix:

Consent (Explicit) + custom 4.5rem, with
is-style-listremoved from Advanced (Row 4)Before fix:

After fix:

#jetpack-happy-ai-updates