Skip to content

Commit 78090d1

Browse files
talldanmatticbot
authored andcommitted
Forms: Prevent custom label font size from preventing scaling in animated and outline block styles (#42248)
* Forms: Fix relative font sizes for animated and outline block styles * changelog * Switch to CSS vars to bridge markup discrepancy between editor and frontend Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/14026335843 Upstream-Ref: Automattic/jetpack@44d1784
1 parent b1acdad commit 78090d1

File tree

9 files changed

+34
-11
lines changed

9 files changed

+34
-11
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This is an alpha version! The changes listed here are not final.
1515

1616
### Fixed
1717
- Components: Add __next40pxDefaultSize to controls, preventing deprecation notices.
18+
- Forms: Prevent custom label font sizes preventing animated label font size reduction
1819
- Placeholder should always display if it's a non-empty string
1920

2021
## [0.43.0] - 2025-03-18

dist/blocks/editor.asset.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('jetpack-connection', 'jetpack-script-data', 'lodash', 'react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill', 'wp-primitives', 'wp-url'), 'version' => '8220c11ec0c3dbb316fe');
1+
<?php return array('dependencies' => array('jetpack-connection', 'jetpack-script-data', 'lodash', 'react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill', 'wp-primitives', 'wp-url'), 'version' => '5294834b327d250a838c');

dist/blocks/editor.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/blocks/editor.js

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/blocks/editor.rtl.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/contact-form/css/grunion-rtl.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/contact-form/css/grunion.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/contact-form/class-contact-form-field.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ public function render() {
347347
$this->label_styles .= 'color: ' . esc_attr( $this->get_attribute( 'labelcolor' ) ) . ';';
348348
}
349349
if ( ! empty( $this->get_attribute( 'labelfontsize' ) ) ) {
350-
$this->label_styles .= 'font-size: ' . esc_attr( $this->get_attribute( 'labelfontsize' ) ) . ';';
350+
$this->label_styles .= '--jetpack--contact-form--label--font-size:' . esc_attr( $this->get_attribute( 'labelfontsize' ) ) . ';';
351351
}
352352
if ( is_numeric( $this->get_attribute( 'labellineheight' ) ) ) {
353353
$this->label_styles .= 'line-height: ' . (int) $this->get_attribute( 'labellineheight' ) . ';';

src/contact-form/css/grunion.css

+22
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@
107107
flex: 1;
108108
}
109109

110+
.contact-form label[style*="--jetpack--contact-form--label--font-size"] {
111+
font-size: var(--jetpack--contact-form--label--font-size);
112+
}
113+
110114
.contact-form .grunion-checkbox-multiple-options,
111115
.contact-form .grunion-radio-options {
112116
display: flex;
@@ -522,6 +526,16 @@ on production builds, the attributes are being reordered, causing side-effects
522526
font-size: 0.8em;
523527
}
524528

529+
/* The following is scoped by the presence of the custom font size CSS var to avoid needing conditional fallback within the var() */
530+
.contact-form .is-style-outlined .grunion-field-wrap .grunion-field:focus ~ .notched-label .notched-label__label[style*="--jetpack--contact-form--label--font-size"],
531+
.contact-form .is-style-outlined .grunion-field-wrap .grunion-field:not(:placeholder-shown) ~ .notched-label .notched-label__label[style*="--jetpack--contact-form--label--font-size"],
532+
.contact-form .is-style-outlined .grunion-field-wrap .grunion-field.has-placeholder ~ .notched-label .notched-label__label[style*="--jetpack--contact-form--label--font-size"],
533+
.contact-form .is-style-outlined .grunion-field-wrap .grunion-checkbox-multiple-options ~ .notched-label .notched-label__label[style*="--jetpack--contact-form--label--font-size"],
534+
.contact-form .is-style-outlined .grunion-field-wrap .grunion-radio-options ~ .notched-label .notched-label__label[style*="--jetpack--contact-form--label--font-size"],
535+
.contact-form .is-style-outlined .grunion-field-wrap.grunion-field-select-wrap .notched-label .notched-label__label[style*="--jetpack--contact-form--label--font-size"] {
536+
font-size: calc(var(--jetpack--contact-form--label--font-size) * 0.8);
537+
}
538+
525539
.contact-form .is-style-outlined .grunion-field-wrap > input,
526540
.contact-form .is-style-outlined .grunion-field-wrap > textarea,
527541
.contact-form .is-style-outlined .grunion-field-wrap select
@@ -590,6 +604,14 @@ on production builds, the attributes are being reordered, causing side-effects
590604
top: calc(2px + var(--jetpack--contact-form--border-size));
591605
}
592606

607+
/* The following is scoped by the presence of the custom font size CSS var to avoid needing conditional fallback within the var() */
608+
.contact-form .is-style-animated .grunion-field-wrap .grunion-field:focus ~ .animated-label__label[style*="--jetpack--contact-form--label--font-size"],
609+
.contact-form .is-style-animated .grunion-field-wrap .grunion-field:not(:placeholder-shown) ~ .animated-label__label[style*="--jetpack--contact-form--label--font-size"],
610+
.contact-form .is-style-animated .grunion-field-wrap .grunion-field.has-placeholder ~ .animated-label__label[style*="--jetpack--contact-form--label--font-size"],
611+
.contact-form .is-style-animated .grunion-field-wrap.grunion-field-select-wrap .animated-label__label[style*="--jetpack--contact-form--label--font-size"] {
612+
font-size: calc(var(--jetpack--contact-form--label--font-size) * 0.75);
613+
}
614+
593615
.contact-form .is-style-animated .grunion-field-wrap .grunion-checkbox-multiple-options ~ .animated-label__label,
594616
.contact-form .is-style-animated .grunion-field-wrap .grunion-radio-options ~ .animated-label__label {
595617
top: 0;

0 commit comments

Comments
 (0)