Repository navigation
Forms: Fix CSS specificity for compatibility with global styles on the frontend - #43299
Conversation
|
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 🤖 🔴 Action required: Please add missing changelog entries for the following projects: Use the Jetpack CLI tool to generate changelog entries by running the following command: Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
There was a problem hiding this comment.
The changes in this file are probably the most notable change, the rest was fairly routine.
Here I had to move the wp-block-jetpack-option classname to a parent element. Previously it was only applied to the label, but that means that when the user changes the font size for an option, only the label's font size changes. The behavior in trunk (and in the editor after my last PR) is that the input should scale with the label.
Steps to repro:
- Insert Single Choice and Multiple Choice blocks into the editor
- Add some options to those blocks
- Selecting one of the options, increase the font size to XXL
- Save and view the frontend
Expected: The input (checkbox or radio button) should be a similar size to the label next to it
andrewserong
left a comment
There was a problem hiding this comment.
Nice work here, this is testing well for me so far across a half dozen or so block themes. Will continue testing more tomorrow!
There was a problem hiding this comment.
I think I might have found one case where this is still overriding what I set in global styles on the Option block. In my test site, I've set the Option block to have semi-bold styles, and it's working in the site editor, however on the site frontend this rule wins out. Is that because we've moved .wp-block-jetpack-option up a level to the wrapper, so inheriting from that font-weight loses when compared to this rule?
I'm not sure what the right fix would be, but I see you've used inherit for the font size. Could a similar approach work for font-weight, with the default set on the wrapper? Just a thought!
There was a problem hiding this comment.
Nice catch! That should be fixed now. I did it the way you suggested by inheriting the font weight. 👍
There was a problem hiding this comment.
There was a problem hiding this comment.
That was probably accidental, not sure why I would've deleted that line. 🤔
There was a problem hiding this comment.
It looks like another similar issue is that the block styles are applying inconsistently to the input. Block styles are only applying to the option label, whereas global styles are applying to the label and input.
Here I've set the global style color for the option to orange, and the block style color for the orange to green:

I need to double check trunk to make sure I've got this right (I think with the button style, both the label and input should receive a color).
edit: yep, so to match trunk, both the input and label should receive block and global colors.
There was a problem hiding this comment.
I think I've fixed all the issues in this thread now 🤞
andrewserong
left a comment
There was a problem hiding this comment.
Looking pretty close to me — just added comments of the only two issues I've encountered so far.
…le options fields
… font color due to css specificity
…pplying to correct element
886eee8 to
8be1607
Compare
…d some back compat for default css styles
| $option_classes = empty( $option['class'] ) ? $default_classes : $default_classes . ' ' . $option['class']; | ||
|
|
||
| $field .= "<p class='contact-form-field'>"; | ||
| $field .= "<p {$option_styles} class='{$option_classes}'>"; |
There was a problem hiding this comment.
As well as the option classes, I've also moved the option inline styles to the option block wrapper element for consistency. It all seems to work as expected from what I can tell.
One weird issue I've noticed is if you apply text decoration to an option that has the button style variation active, the checkmark also looks like it also has text decoration, and setting text-decoration: none on the pseudoelement doesn't solve it:

This stack overflow answer explains it - https://stackoverflow.com/questions/1238881/text-decoration-and-the-after-pseudo-element-revisited#comment1071169_1239140 - it's not actually the text decoration applying to the pseudo element, the pseudo element is being rendered over the top of the text decoration, so that's why it can't be turned off.
It was also an issue before, this change.
There was a problem hiding this comment.
Seems to be working well to me, too!
andrewserong
left a comment
There was a problem hiding this comment.
Thanks for the updates @talldan, this is testing great for me! I reckon it's in a good place to merge into the main PR 👍
I noticed one curiosity with the font-weight: 400 reset for option(s). I'm pretty sure this predates the inner blocks refactor, so just noted it as a "thing I noticed" but not something that I think we need to fix right now. (I.e. it could be a thing to look into after the refactor as it doesn't block block-level global styles)
LGTM! 🚀
| .contact-form label.consent { | ||
| .contact-form :where(label.consent) { | ||
| font-size: 13px; | ||
| font-weight: 400; |
There was a problem hiding this comment.
While re-testing, I just noticed that I think the default font-weight: 400 overwrites a theme's overall fontWeight set in theme.json. For example, TT5 theme sets font-weight: 300 and this gets overwritten to 400, whereas in the editor it doesn't get overwritten:
So, there could be an opportunity to further reduce the specificity of font-weight rules so that they play nicely with global font-weight set across a theme. However, I think this is likely out of scope for the current exercise as I imagine these 400 rules pre-exist the inner blocks refactor?
For now, since this PR reduces the font-weight so that it's compatible with setting block-level font weight in global styles, I think we've achieved the desired specificity reduction, and I'm aware it's very easy to accidentally increase scope of tasks right now.
So IMO not a blocker for proceeding with this change 👍
There was a problem hiding this comment.
I've made an issue (FORMS-41) to track that.
| .contact-form :where(label.checkbox-multiple), | ||
| .contact-form :where(label.radio), | ||
| .contact-form :where(label.checkbox) { | ||
|
|
There was a problem hiding this comment.
Tiniest of nits: unintended single line whitespace? (not a blocker)
There was a problem hiding this comment.
Unfortunately Jetpack's linter auto adds this above any comments (there's one on the following line).
There was a problem hiding this comment.
Ah, good to know! Ignore me then 🙂
ramonjd
left a comment
There was a problem hiding this comment.
LGTM
Tested styles according to instructions using a couple of themes. 👍🏻
Frontend appears as expected 🚀
…e frontend (#43299) * Fix consent field label css specificity preventing global typography styles * Fix checkbox/radio option font-weight css specificity preventing global styles * Remove empty line and duplicate classname * Fix mixed spaces/tabs indentation * Fix checkbox/radio input not scaling with font size for single/multiple options fields * Fix indentation * Fix button style multiple choice checkbox not receiving global styles font color due to css specificity * Fix single choice option not receiving text color due to styles not applying to correct element * Reinstate missing color style * Move option block style classnames to parent wrapper on frontend * Make option label font weight inherited from parent block wrapper, add some back compat for default css styles * Fix tests * Move option styles to parent block level element
…e frontend (#43299) * Fix consent field label css specificity preventing global typography styles * Fix checkbox/radio option font-weight css specificity preventing global styles * Remove empty line and duplicate classname * Fix mixed spaces/tabs indentation * Fix checkbox/radio input not scaling with font size for single/multiple options fields * Fix indentation * Fix button style multiple choice checkbox not receiving global styles font color due to css specificity * Fix single choice option not receiving text color due to styles not applying to correct element * Reinstate missing color style * Move option block style classnames to parent wrapper on frontend * Make option label font weight inherited from parent block wrapper, add some back compat for default css styles * Fix tests * Move option styles to parent block level element
…e frontend (#43299) * Fix consent field label css specificity preventing global typography styles * Fix checkbox/radio option font-weight css specificity preventing global styles * Remove empty line and duplicate classname * Fix mixed spaces/tabs indentation * Fix checkbox/radio input not scaling with font size for single/multiple options fields * Fix indentation * Fix button style multiple choice checkbox not receiving global styles font color due to css specificity * Fix single choice option not receiving text color due to styles not applying to correct element * Reinstate missing color style * Move option block style classnames to parent wrapper on frontend * Make option label font weight inherited from parent block wrapper, add some back compat for default css styles * Fix tests * Move option styles to parent block level element
…e frontend (#43299) * Fix consent field label css specificity preventing global typography styles * Fix checkbox/radio option font-weight css specificity preventing global styles * Remove empty line and duplicate classname * Fix mixed spaces/tabs indentation * Fix checkbox/radio input not scaling with font size for single/multiple options fields * Fix indentation * Fix button style multiple choice checkbox not receiving global styles font color due to css specificity * Fix single choice option not receiving text color due to styles not applying to correct element * Reinstate missing color style * Move option block style classnames to parent wrapper on frontend * Make option label font weight inherited from parent block wrapper, add some back compat for default css styles * Fix tests * Move option styles to parent block level element
…e frontend (#43299) * Fix consent field label css specificity preventing global typography styles * Fix checkbox/radio option font-weight css specificity preventing global styles * Remove empty line and duplicate classname * Fix mixed spaces/tabs indentation * Fix checkbox/radio input not scaling with font size for single/multiple options fields * Fix indentation * Fix button style multiple choice checkbox not receiving global styles font color due to css specificity * Fix single choice option not receiving text color due to styles not applying to correct element * Reinstate missing color style * Move option block style classnames to parent wrapper on frontend * Make option label font weight inherited from parent block wrapper, add some back compat for default css styles * Fix tests * Move option styles to parent block level element
* Add base form field blocks Introduces foundational form field blocks: - jetpack/input - jetpack/label - jetpack/option - jetpack/options These blocks will be reused across all field types using inner blocks. * changelog * Fix issues with style syncing hook: - Prevents adding bulk changes when syncing blocks to the undo stack - Correctly determines the parent field block for option blocks to check if syncing is enabled - Correctly find all option blocks regardless of whether they are a field's direct child, e.g. consent, or nested within an options block e.g. single/multiple choice fields. * Prevent style syncing when blocks are reused in previews * Ensure label is editable after being emptied and placeholder shows * Opt out of block gap spacing for Options block This is an enhancement over trunk however the is some work required to make this actually work, especially given the shortcode rendering on the frontend. For the time being this support will explicitly be opted out of. It can be revisited when the benefit justifies the additional complexity and work. * Migrate form field blocks to use new base blocks Updates legacy form field blocks to use shared inner blocks: - jetpack/input - jetpack/label - jetpack/option - jetpack/options This commit also updates the registration of form blocks so the new shared blocks are available in the editor. * changelog * Fix CSS linting issues * Make select dropdown field's edit component more robust * First pass at updating form variations * Quick clean up of form variations * Pass required block toolbar control through to Option block for checkbox field * Clean up form field and inner block attributes * Remove lodash dependency from dropdown field edit component * Remove remaining lodash uses in new or updated form blocks * Remove TODO as Dropdown fields didn't use option styles * Fix default styling for Consent field option label * Clean up unrequired TODO item * Clean some more TODOs * Restore empty string defaults for input, option, and label blocks * Revert use sync style hook to previous version retaining undo stack fix * Fix typo Co-authored-by: Ramon <ramonjd@users.noreply.github.com> * Update form field style syncing (#43004) * Refactor and update form field syncing. - Use a parent react context provider as the source of truth instead of an arbitrary sibling block. - Perform a deep equality check before syncing to prevent against spurious updates. * When updating the block own attributes, mark the change as not persistent so that the user can undo * Prime the previousOwnAttributes value so that we avoid updating syncedAttributes unnecessarily * Update inline docs * Prime the synced attributes when they are initially unset * Fix syncing of styles across checkbox and consent options --------- Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> * Fix linting error in editor.scss * Attempt to fix warnings about PhanUndeclaredTypeParameter for WP_Block * Fix linting issue in class-contact-form.php * Forms: Prevent errors when synced attribute context is not available (#43027) * Forms: Fix error thrown in previews for synced form fields * Clean up * Rename the context type stuff * For html_entity_decode, use ENT_COMPAT since we only care about double quotes for the purposes of JSON decoding * Remove is_array and empty check as we now will always have at least one 'class' attribute on the extra_attrs array * Add transforms for new inner blocks based fields * Clean up standalone checkbox inner blocks template * Clean up dropdown field inner blocks template * Add example definitions for field block types * Allow default checked status for standalone option fields * Fix choice field deprecation edge case * Fix handling of required and width attributes for Textarea field. * Fix label block's placeholder fallbacks * Fix form undo redo issues (#43036) * Fix undo stack issue with useFormWrapper * Fix undo stack issue with text area * Fix undo stack issue with duplicated useFormWrapper * Fix undo stack issue with consent field block * Fix undoing after selecting a block variation causing multiple undo steps * Fix comment typos Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> * Remove `required` property from template This is now provided to the child block through context Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> --------- Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> * Forms: Add PHP unit tests for Migrate form fields to inner blocks JETPACK-262 (#43002) * inital commit - exploratory * do_shortcode * Add test_block_attributes_to_shortcode_attributes_with_styles * add more simple tests * remove unnecessary changes * changelog * LINTO! * Adding WP namespaces * test_gutenblock_render_field_checkbox * Add test for trim * Use optionsdata to presume that block_attributes_to_shortcode_attributes has taken place. Let's test that as a unit * Adding classes and styles in attributes. * block_attributes_to_shortcode_attributes tests * text field which has input and label * Phan complains about \DOMNode::getAttribute. Shut it up. * Try to quiet Phan again by passing a WP_Block instance * Attempt to fix a couple of the code coverage warnings * Try to fix namespace again * Try using the full namespace for the covers annotation instead of the relative name --------- Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com> * Clean up TODO as the important style for Outlined form style can not be avoided * Remove extraneous hook dependency * Remove useFormWrapper audit TODO - all fields use it * Remove TODOs already captured by issues * Remove unused ids from consent, checkbox, single choice and multiple choice fields (#43055) * Fix saving and display of dropdown field placeholder * Fix dropdown field placeholder default This commit also updates the dropdown field input's styles to make it easier to click when the placeholder has previously been cleared. * Fix style linting error * Form inner blocks: supplement existing PHP unit tests (#43076) * Enhance unit tests for Contact_Form_Block by adding support checks This commit updates the `test_register_child_blocks` method to include an optional parameter for expected block supports and introduces a new test method, `test_child_blocks_block_supports`, to verify the configuration of block supports for various Jetpack blocks. The data provider for the new test method is also added, ensuring comprehensive testing of block support attributes. * Add unit test for gutenblock_render_field_radio method This commit introduces a new test method, `test_gutenblock_gutenblock_render_field_radio`, to validate the rendering of the radio field block in the Contact Form Plugin. The test checks that the generated shortcode matches the expected output, ensuring proper functionality of the radio field block with various attributes and inner blocks. * changelog * remove duplicate tests. silly me! * Apply suggestions from code review Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> * syncing server block supports with frontend * try again --------- Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> * Allow default checked status for standalone option fields (#43077) * Fix date picker field incorrect classname (#43059) * Ensure jetpack-field__input classname applies to date picker input instead of jetpack-field__date * Remove explicit date type in appointment form variation * Specify the field type for the date field in the block template * Iron out inconsistency of date type for date picker inputs * Tied up text fields array --------- Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> * Revert "Remove deprecated covers annotations in line with #42902" This reverts commit 38791a8. Restoring these in case they were in place for coverage requirements. * Forms: move @Covers to class level in PHP unit tests (#43081) * Hoist @cover annotations to class level. * changelog * Fix field block examples (#43096) * Fix field block examples being altered by useFormWrapper useFormWrapper adds a form wrapper around any field that doesn't have one. It wasn't preserving the field's own inner blocks, which became visible in the block examples, where single or multiple choice fields have inner blocks but no wrapper. This PR ensures the inner blocks are preserved by calling getBlocks to get the inner blocks of the field and passing that as the inner blocks in the replaceBlocks call within useFormWrapper. * Small improvement to variable name * Add missing useEffect deps * Fix select/dropdown example * Switch e2e test close welcome guide code to use preferences * Forms: Fix display of label and option fallback values in transform previews JETPACK-278 (#43100) * Add fallback styles for dropdown block when css vars are not populated (#43101) * Add missed cleaned up label fallback handling * Fix rendering of legend as a label - Ensure block class is added to legend element - Add custom block classes and styles to legend - Tweak default style specificity so global styles can apply * Remove redundant array check to make linter happy. * Clean up dead code in shared JetpackFieldControls * Try to fix metadata in doc comments warning * Try updating PHP test attributes again, to hopefully please the linter * Forms: ensure custom CSS in global styles applies correctly to checkbox and radio wrappers (#43184) * Refactor class attribute handling in Contact_Form_Field - Trimmed type variable to ensure consistent class generation. - Added specific classes for 'checkbox-multiple' and 'radio' types. - Included TODOs for potential improvements and testing. * changelog * Add block styles for checkbox-multiple and radio fields - Registered new block styles for 'jetpack/field-checkbox-multiple' and 'jetpack/field-radio'. - Updated class handling in Contact_Form_Field to ensure proper application of styles. - Adjusted CSS selectors to reflect changes in class structure for button styles. * Enhance class handling for checkbox-multiple and radio fields - Updated Contact_Form_Field to apply block style classes to wrapper divs for checkbox-multiple and radio types. - Introduced a new method to extract block style classes from the class attribute. - Modified tests to validate the addition of block style classes in the rendering process. * Refactor block style registration for checkbox-multiple and radio fields - Consolidated block style registration for 'jetpack/field-checkbox-multiple' and 'jetpack/field-radio' into a single call. - Updated comments to clarify the purpose of style registration and future improvements. - Adjusted class handling in Contact_Form_Field to include new class naming conventions. * Refactor block style application for checkbox-multiple and radio fields - Streamlined the handling of block style classes for 'checkbox-multiple' and 'radio' types in Contact_Form_Field. - Improved code readability by consolidating conditional checks for block style class assignment. - Ensured consistent application of styles to wrapper divs for both field types. * Enhance radio field rendering tests and block style application - Added tests to validate rendering of radio fields with block style classes. - Improved handling of block style classes for radio fields in Contact_Form_Field to ensure consistent application. - Updated assertions in tests to reflect changes in class structure for radio fields. * Remove outdated changelog entry for migrating form fields to inner blocks with multiple wrapper styles * Enhance field wrapper class handling for contact form fields - Introduced 'fieldwrapperclasses' attribute to allow custom wrapper classes for form fields. - Updated rendering logic in Contact_Form_Field to utilize the new attribute for consistent styling. - Refactored tests to validate the addition of 'fieldwrapperclasses' for various field types, ensuring proper application of block styles. * Try fixing a linting issue with the DataProvider --------- Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com> * Add icons for input, label, option, and options blocks (#43270) * Form Global Styles: Update CSS specificity to 0-1-0 for default editor styles (excluding outlined style) (#43125) * Reduce specificity of text area styles to 0-1-0 * Update specificity of option block styles * Fix option input not scaling with font size for single/multiple choice fields * Fix font:inherit rule overriding global styles font family setting by reduce specificity * Add dead code comments * Forms: only apply `wp-` and `is-style-` classes to fields of new inner block types (#43268) * Only apply the block style classes to the field wrapper if the field is one of the new inner block types. * update tests * Refactor get_block_style_classes to return field wrapper classes and simplify class handling * Ensure there's no whitespace in unimgrated fields * Fix missing checkmark for single choice options on frontend (#43301) * Forms: Fix CSS specificity for compatibility with global styles on the frontend (#43299) * Fix consent field label css specificity preventing global typography styles * Fix checkbox/radio option font-weight css specificity preventing global styles * Remove empty line and duplicate classname * Fix mixed spaces/tabs indentation * Fix checkbox/radio input not scaling with font size for single/multiple options fields * Fix indentation * Fix button style multiple choice checkbox not receiving global styles font color due to css specificity * Fix single choice option not receiving text color due to styles not applying to correct element * Reinstate missing color style * Move option block style classnames to parent wrapper on frontend * Make option label font weight inherited from parent block wrapper, add some back compat for default css styles * Fix tests * Move option styles to parent block level element * Forms: remove color gradients block supports (#43427) * Forms: Update gradient property naming in contact form block and tests to ensure consistency * Forms: Update gradient property naming to 'gradients' for consistency in input and option blocks * Fix label typo --------- Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com> * [WIP] Forms: migrate Outlined form style for inner block based fields (#43327) * first commit * backend mania * Removing dividing two top of label. Can reinstate * fix number conversion * Match legacy form behaviour when deriving px values for CSS vars * color, typography * Adjust clip path to cater for 1px borders * Implement outline style support for form fields by integrating useFormStyleOutlineClassesAndStyles hook across various blocks. Update CSS variables and styles for outlined and animated form styles in the contact form backend and frontend components. * Cannot fix overlap right now * Trying to fix select, options, etc * desperately trying to assign the right values to css vars * get background working * path to syncing options * use lodash for merging * global styles specificity * Remove isSynced from hook and related code * Try only using hook on label * Inject CSS vars for input as well as label so that it can calculate correct padding * Call it a jetpack contact form notch width * Fix overflowing background when a narrow border-width is set * Fix input block placeholders not selectable/visible when outlined style is active * Fix animated style label and input offset * Animated style: fix label and input offset when using distinct border left style in editor * Fix trailing notch background color * Inputs should take border radius styles so they match the notched border. Fix global style derivation for borders * Fix incorrect block names Co-authored-by: Ramon <ramonjd@users.noreply.github.com> * Improve support for split border radii in outlined form style * Remove min width for notch * This commit syncs jetpack/options with jetpack/input * abstract get inner block hook * esc notched attrs * Check $legacy values before assignment * move css vars to inner elems * Apply the background to the notch elements again instead of the input to ensure border aligns with background. Remove the z-index rule so that the input/placeholder is visible and can be edited * Adding padding where there's a border Enhance contact form styles and structure by adding support for animated styles, adjusting border colors, and refining fieldset rendering logic. * Add filler notch element on frontend * Fix flex shrink/grow of notch elements with new filler notch element * Limit padding of inputs to support a wider range of border radii units This helps prevent situations where the calculated padding can end up being a huge number when units like % are used. 100% might make sense for a border radius, but that value used for a padding is huge. Cap the padding at 100px to match trunk's max border radius value. * Ensure dropdowns have same styles for input as other fields, DRY up * Updated rendering logic in the contact form fields to differentiate between outlined and animated styles. Introduced a new helper function to manage outlined style attributes and adjusted CSS to ensure proper styling for outlined fields. Cleaned up related code for clarity and maintainability. * Ensure default padding for outlined styles in inputs * Refactor contact form styles to ensure global styles can override default border and padding settings. Updated class logic for option groups to conditionally apply border styles based on attributes, enhancing flexibility and maintainability. * Account for split border radius when calculating css var on the frontend * Set a max width for any elements using --jetpack--contact-form--notch-width of 100px * Update tests with new shortcode attributes and styles for outline and options * Switch inputs and labels for the outlined and animated style so that label is above input * Remove background on inputs for outlined style, background is being applied to labels instead * Add filler notch element to match editor styles * Add max-width for trailing notch element * Fix border radius css var not picking up single values with a unit * Remove border radius and clip path on inputs for outlined style (border radius is applied on the label, clip path does nothing) * Update tests with new attributes and outline HTML * Default white background in the editor * Ensure the Button variation on the Multiple Choice (Checkbox) block inherits the current color from the option block. * Add background color support for outlined style in contact form inputs and update related tests * Fix outlined border radius for checkbox multiple * Fix css border-radius var calculation * Fix checkbox multiple radius for outlined style * Small tidy up * Enhance outline styles handling in contact form fields by adding form style parameter and refining border radius calculations. Update CSS to include z-index for animated labels. * Apply outlined border radius style to radio fields to match other fields * Remove spaces in inline styles * Select arrow position, default padding for has-background * Padding magic on the options in outlined * Add font size adjustment for legend in outlined contact form style * Fix position of legend and right padding for options * Remove export of constant * Combine is_outlined `if` statements for checkbox multiple * Combine is_outlined `if` statements for radio * Rename useFormStyleOutlineClassesAndStyles to useVariationStyleProperties * Only memoize based on changes to block type when merging global styles * Add documentation to useVariationStyleProperties * Small tidy up, rename a function and add docs * Remove commented out css declarations * Remove dead code. Context is unused. Anywhere. Go look if you don't believe me. --------- Co-authored-by: Daniel Richards <daniel.richards@automattic.com> * Add esc_attr calls to render_radio_field (#43488) * Reinstate default padding where there's a border. Add option chaining to innerBlock look up as trunk forms won't have it. * Use correct block name in get_ouline_styles (#43489) * Forms: standardize animated variation style paddings (#43469) * Update padding for animated style * Fix updated function * Rename get_outline_styles * check borderradius * Calculate border widths with all sides via CSS vars * Fix text area top position * Reinstate default (trunk) padding for animated labels etc * Default value of null on border sizes * Remove dupe CSS * JS Doc :success: * Add legacy CSS var as default * Use the `borderwidth` field attribute as the legacy legacy border width value * Explain use of `borderwidth` value * Update projects/packages/forms/src/contact-form/class-contact-form-field.php Use var `$border_width_attribute` * Add bottom width CSS var to backend, and use border sides in the notched CSS * Remove styles that we're overriding * Switch from !empty to isset for legacy borderwidth attribute check * Do empty/zero check on legacy border widths --------- Co-authored-by: Daniel Richards <daniel.richards@automattic.com> * Forms: Fix block instance border color not overriding global styles border color with outlined style active (on the frontend) (#43532) * Allow block instance border color to override global styles border color * Remove extra space in class name * Revert input + option syncing. Bad! * Forms: Fix typography input styles applying to labels when outline style is active (on frontend) (#43534) * Fix rogue typography attributes from input applying to label * Fix bad rebase * Update tests * For classic themes, do not destructure theme config objects that don't exist. * Forms: Fix custom classnames support in inner blocks migration (#43564) * Forms: fix custom class handling in contact form plugin (#43587) * Forms: Enhance class handling in contact form plugin and tests - Updated class handling in `class-contact-form-plugin.php` to filter empty block style classes. - Modified test cases in `Contact_Form_Plugin_Test.php` and `Contact_Form_Test.php` to include additional attributes and ensure proper class wrapping for various field types. - Improved assertions to validate class attributes in rendered output. * Make innerblocks optional. Just for linting * Forms: Fix outline style label font size (#43590) * Fix text input-style field label font size when outlined style is active. * Remove scaling using variable * Fix scaling of multiple option fields when using outlined style * Tidy up styles * Wrap labels * Fix outlined label font size and animation * Fix animation by ensuring top is a valid value * Remove will-change: transform on frontend too. Transform usually does not change. * Forms: fix inconsistent weights in outline style and terms labels (#43545) * Ensure that existing font-weight styles do not override block and global label styles. * Consent weights * Revert options positioning kram * Increase specificity to 0 1 0 for classic themes * Bump specificity of consent label * Bump specificity * Forms: Fix animated style label font scaling (#43615) * Fix animated style label font size in editor * Add span wrapper around label text * Update animated label styles on frontend * Size and animation adjustments for required text * Fix label animating when selected in editor if using the animated form style variation and no placeholder is set * Forms Fix animated label centered positioning (#43635) * Fix animated label vertical centering when using uneven borders in the input * Remove unused cass var * Forms: Remove options text color support (#43612) * Remove text color support for jetpack/options, since frontend does not replicate the markup of the editor and so style parity cannot be achieved * Try to fix tests * Whoops, wrong flag * One more time --------- Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com> * Forms: options block layout tweaks (#43531) * Refactor contact form styles and rendering logic to enhance alignment and maintainability. Update CSS for radio and checkbox options to use consistent alignment, and streamline fieldset and div class attributes by removing unnecessary prefixes. Improve handling of border styles and attributes for outlined forms, ensuring compatibility with global styles. * Try baseline for the options * Revert changes to "fix" option alignment * Revert option alignment v2 * Add classes to tests * Reinstate tweaks for option positioning * Apply wp-block-jetpack-option class in the attribute migration method * Use em instead of rem. Remove unnecessary tweaks * Border support for classic themes * Ensure radio inputs don't warp in classic themes. Update options description * Force opinionated dimensions on the options inputs * wp-block-jetpack-option was not being applied to inner options blocks * Forms: update padding for jetpack options in contact form to conform with trunk (#43634) * consolidate legends * Remove styles that are inconsistent with existing trunk spacing. (frontend) * Remove padding in editor * editor * The feature branch has different markup for .wp-block-jetpack-options so we need to target the fieldset using different selectors * comments * Fix date field label suffix font size for outlined/animated styles * Fix option input color not inherited in editor * Forms: Update border radius and width handling in deprecateFieldStyles function (#43653) * Attempt to fix warnings about PhanUndeclaredTypeParameter for WP_Block * Forms: Update border radius and width handling in deprecateFieldStyles function * Ensure border radius and width are correctly set to 'undefined' only when they are not provided or are null, allowing for proper handling of zero values. * Coerce lineheight to str * REvert - bad rebase * Update class-contact-form-plugin.php My IDE auto formatted this --------- Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com> * Remove duplicated styles * Form: fix default fallbacks for unmigrated forms (#43676) * Outlined multi option backgrounds defaults * Don't concat the label and option styles for consent and single option in unmigrated forms * PHPCS warning - Use statements are not alphabetically sorted (MediaWiki.Classes.UnsortedUseStatements.UnsortedUse * Forms: tame select arrow positioning (#43674) * initial commit - adding extra markup to the select rendering and fixing positioning of labels * uncommenting * Remove default select border * Update select field rendering to include a wrapper div with the correct class structure for improved styling and consistency in tests. * Update contact form styles to inherit text color and adjust z-index for select wrapper elements * Only run `getAttribute` on select wrapper if there is one * Reinstate padding change * phan me * phanos * whitespace * Ensure that animated labels sit above active input elements. * Forms: account for missing placeholder when transforming input fields to select dropdown and fix z-index (#43721) * Enhance select field transformation by adding default placeholder for input block. Update contact form plugin to correctly reference placeholder attribute. Adjust z-index values in CSS for improved label positioning. * Update z-index values in contact form CSS for improved label positioning and remove redundant styles for outlined fields. * Complete CSS comment * Refactor select field transformation to set placeholder attribute directly from attributes. Remove redundant placeholder handling in inner block creation. * Revert createTextFieldInnerBlocks * Revert experiment. Add default placeholder for select in createTextFieldInnerBlocks * Don't mutate the attributes object * Don't spread optional chaining just in case * Update contact form styles to prevent color overrides by global styles. Add 'color: unset !important;' to both editor.scss and grunion.css for consistent input appearance. (#43737) * Fix consent field spacing between checkbox and label (#43743) * Update context types to use kebab casing (#43740) * Forms: Fix required form field validation for options blocks in the inner blocks refactor (#43738) * Update accessible form selectors for single/multiple choice fields (#43760) * Forms: refactor placeholder handling for outlined and styled forms (#43759) * Forms: Refactor placeholder handling in contact form fields * Simplify placeholder logic to ensure consistent rendering of input fields. * Remove unnecessary conditionals for placeholder assignment and improve code clarity. * Forms: Update contact form styles and placeholder handling * Adjusted placeholder logic to ensure it only renders when a value is present, improving input field consistency. * Updated the contact form stylesheet to include a version query string for better cache management. * Commented out specific CSS rules to prevent unintended side effects related to placeholder visibility in outlined and animated label styles. * Remove other :not(:placeholder-shown) styles * Remove multiple changelogs for branches that were never merged to trunk --------- Co-authored-by: Ramon <ramonjd@users.noreply.github.com> Co-authored-by: Daniel Richards <daniel.richards@automattic.com> Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com> Co-authored-by: Ramon <ramonjd@gmail.com>
* Add base form field blocks Introduces foundational form field blocks: - jetpack/input - jetpack/label - jetpack/option - jetpack/options These blocks will be reused across all field types using inner blocks. * changelog * Fix issues with style syncing hook: - Prevents adding bulk changes when syncing blocks to the undo stack - Correctly determines the parent field block for option blocks to check if syncing is enabled - Correctly find all option blocks regardless of whether they are a field's direct child, e.g. consent, or nested within an options block e.g. single/multiple choice fields. * Prevent style syncing when blocks are reused in previews * Ensure label is editable after being emptied and placeholder shows * Opt out of block gap spacing for Options block This is an enhancement over trunk however the is some work required to make this actually work, especially given the shortcode rendering on the frontend. For the time being this support will explicitly be opted out of. It can be revisited when the benefit justifies the additional complexity and work. * Migrate form field blocks to use new base blocks Updates legacy form field blocks to use shared inner blocks: - jetpack/input - jetpack/label - jetpack/option - jetpack/options This commit also updates the registration of form blocks so the new shared blocks are available in the editor. * changelog * Fix CSS linting issues * Make select dropdown field's edit component more robust * First pass at updating form variations * Quick clean up of form variations * Pass required block toolbar control through to Option block for checkbox field * Clean up form field and inner block attributes * Remove lodash dependency from dropdown field edit component * Remove remaining lodash uses in new or updated form blocks * Remove TODO as Dropdown fields didn't use option styles * Fix default styling for Consent field option label * Clean up unrequired TODO item * Clean some more TODOs * Restore empty string defaults for input, option, and label blocks * Revert use sync style hook to previous version retaining undo stack fix * Fix typo Co-authored-by: Ramon <ramonjd@users.noreply.github.com> * Update form field style syncing (#43004) * Refactor and update form field syncing. - Use a parent react context provider as the source of truth instead of an arbitrary sibling block. - Perform a deep equality check before syncing to prevent against spurious updates. * When updating the block own attributes, mark the change as not persistent so that the user can undo * Prime the previousOwnAttributes value so that we avoid updating syncedAttributes unnecessarily * Update inline docs * Prime the synced attributes when they are initially unset * Fix syncing of styles across checkbox and consent options --------- Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> * Fix linting error in editor.scss * Attempt to fix warnings about PhanUndeclaredTypeParameter for WP_Block * Fix linting issue in class-contact-form.php * Forms: Prevent errors when synced attribute context is not available (#43027) * Forms: Fix error thrown in previews for synced form fields * Clean up * Rename the context type stuff * For html_entity_decode, use ENT_COMPAT since we only care about double quotes for the purposes of JSON decoding * Remove is_array and empty check as we now will always have at least one 'class' attribute on the extra_attrs array * Add transforms for new inner blocks based fields * Clean up standalone checkbox inner blocks template * Clean up dropdown field inner blocks template * Add example definitions for field block types * Allow default checked status for standalone option fields * Fix choice field deprecation edge case * Fix handling of required and width attributes for Textarea field. * Fix label block's placeholder fallbacks * Fix form undo redo issues (#43036) * Fix undo stack issue with useFormWrapper * Fix undo stack issue with text area * Fix undo stack issue with duplicated useFormWrapper * Fix undo stack issue with consent field block * Fix undoing after selecting a block variation causing multiple undo steps * Fix comment typos Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> * Remove `required` property from template This is now provided to the child block through context Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> --------- Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> * Forms: Add PHP unit tests for Migrate form fields to inner blocks JETPACK-262 (#43002) * inital commit - exploratory * do_shortcode * Add test_block_attributes_to_shortcode_attributes_with_styles * add more simple tests * remove unnecessary changes * changelog * LINTO! * Adding WP namespaces * test_gutenblock_render_field_checkbox * Add test for trim * Use optionsdata to presume that block_attributes_to_shortcode_attributes has taken place. Let's test that as a unit * Adding classes and styles in attributes. * block_attributes_to_shortcode_attributes tests * text field which has input and label * Phan complains about \DOMNode::getAttribute. Shut it up. * Try to quiet Phan again by passing a WP_Block instance * Attempt to fix a couple of the code coverage warnings * Try to fix namespace again * Try using the full namespace for the covers annotation instead of the relative name --------- Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com> * Clean up TODO as the important style for Outlined form style can not be avoided * Remove extraneous hook dependency * Remove useFormWrapper audit TODO - all fields use it * Remove TODOs already captured by issues * Remove unused ids from consent, checkbox, single choice and multiple choice fields (#43055) * Fix saving and display of dropdown field placeholder * Fix dropdown field placeholder default This commit also updates the dropdown field input's styles to make it easier to click when the placeholder has previously been cleared. * Fix style linting error * Form inner blocks: supplement existing PHP unit tests (#43076) * Enhance unit tests for Contact_Form_Block by adding support checks This commit updates the `test_register_child_blocks` method to include an optional parameter for expected block supports and introduces a new test method, `test_child_blocks_block_supports`, to verify the configuration of block supports for various Jetpack blocks. The data provider for the new test method is also added, ensuring comprehensive testing of block support attributes. * Add unit test for gutenblock_render_field_radio method This commit introduces a new test method, `test_gutenblock_gutenblock_render_field_radio`, to validate the rendering of the radio field block in the Contact Form Plugin. The test checks that the generated shortcode matches the expected output, ensuring proper functionality of the radio field block with various attributes and inner blocks. * changelog * remove duplicate tests. silly me! * Apply suggestions from code review Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> * syncing server block supports with frontend * try again --------- Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> * Allow default checked status for standalone option fields (#43077) * Fix date picker field incorrect classname (#43059) * Ensure jetpack-field__input classname applies to date picker input instead of jetpack-field__date * Remove explicit date type in appointment form variation * Specify the field type for the date field in the block template * Iron out inconsistency of date type for date picker inputs * Tied up text fields array --------- Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> * Revert "Remove deprecated covers annotations in line with #42902" This reverts commit 38791a8. Restoring these in case they were in place for coverage requirements. * Forms: move @Covers to class level in PHP unit tests (#43081) * Hoist @cover annotations to class level. * changelog * Fix field block examples (#43096) * Fix field block examples being altered by useFormWrapper useFormWrapper adds a form wrapper around any field that doesn't have one. It wasn't preserving the field's own inner blocks, which became visible in the block examples, where single or multiple choice fields have inner blocks but no wrapper. This PR ensures the inner blocks are preserved by calling getBlocks to get the inner blocks of the field and passing that as the inner blocks in the replaceBlocks call within useFormWrapper. * Small improvement to variable name * Add missing useEffect deps * Fix select/dropdown example * Switch e2e test close welcome guide code to use preferences * Forms: Fix display of label and option fallback values in transform previews JETPACK-278 (#43100) * Add fallback styles for dropdown block when css vars are not populated (#43101) * Add missed cleaned up label fallback handling * Fix rendering of legend as a label - Ensure block class is added to legend element - Add custom block classes and styles to legend - Tweak default style specificity so global styles can apply * Remove redundant array check to make linter happy. * Clean up dead code in shared JetpackFieldControls * Try to fix metadata in doc comments warning * Try updating PHP test attributes again, to hopefully please the linter * Forms: ensure custom CSS in global styles applies correctly to checkbox and radio wrappers (#43184) * Refactor class attribute handling in Contact_Form_Field - Trimmed type variable to ensure consistent class generation. - Added specific classes for 'checkbox-multiple' and 'radio' types. - Included TODOs for potential improvements and testing. * changelog * Add block styles for checkbox-multiple and radio fields - Registered new block styles for 'jetpack/field-checkbox-multiple' and 'jetpack/field-radio'. - Updated class handling in Contact_Form_Field to ensure proper application of styles. - Adjusted CSS selectors to reflect changes in class structure for button styles. * Enhance class handling for checkbox-multiple and radio fields - Updated Contact_Form_Field to apply block style classes to wrapper divs for checkbox-multiple and radio types. - Introduced a new method to extract block style classes from the class attribute. - Modified tests to validate the addition of block style classes in the rendering process. * Refactor block style registration for checkbox-multiple and radio fields - Consolidated block style registration for 'jetpack/field-checkbox-multiple' and 'jetpack/field-radio' into a single call. - Updated comments to clarify the purpose of style registration and future improvements. - Adjusted class handling in Contact_Form_Field to include new class naming conventions. * Refactor block style application for checkbox-multiple and radio fields - Streamlined the handling of block style classes for 'checkbox-multiple' and 'radio' types in Contact_Form_Field. - Improved code readability by consolidating conditional checks for block style class assignment. - Ensured consistent application of styles to wrapper divs for both field types. * Enhance radio field rendering tests and block style application - Added tests to validate rendering of radio fields with block style classes. - Improved handling of block style classes for radio fields in Contact_Form_Field to ensure consistent application. - Updated assertions in tests to reflect changes in class structure for radio fields. * Remove outdated changelog entry for migrating form fields to inner blocks with multiple wrapper styles * Enhance field wrapper class handling for contact form fields - Introduced 'fieldwrapperclasses' attribute to allow custom wrapper classes for form fields. - Updated rendering logic in Contact_Form_Field to utilize the new attribute for consistent styling. - Refactored tests to validate the addition of 'fieldwrapperclasses' for various field types, ensuring proper application of block styles. * Try fixing a linting issue with the DataProvider --------- Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com> * Add icons for input, label, option, and options blocks (#43270) * Form Global Styles: Update CSS specificity to 0-1-0 for default editor styles (excluding outlined style) (#43125) * Reduce specificity of text area styles to 0-1-0 * Update specificity of option block styles * Fix option input not scaling with font size for single/multiple choice fields * Fix font:inherit rule overriding global styles font family setting by reduce specificity * Add dead code comments * Forms: only apply `wp-` and `is-style-` classes to fields of new inner block types (#43268) * Only apply the block style classes to the field wrapper if the field is one of the new inner block types. * update tests * Refactor get_block_style_classes to return field wrapper classes and simplify class handling * Ensure there's no whitespace in unimgrated fields * Fix missing checkmark for single choice options on frontend (#43301) * Forms: Fix CSS specificity for compatibility with global styles on the frontend (#43299) * Fix consent field label css specificity preventing global typography styles * Fix checkbox/radio option font-weight css specificity preventing global styles * Remove empty line and duplicate classname * Fix mixed spaces/tabs indentation * Fix checkbox/radio input not scaling with font size for single/multiple options fields * Fix indentation * Fix button style multiple choice checkbox not receiving global styles font color due to css specificity * Fix single choice option not receiving text color due to styles not applying to correct element * Reinstate missing color style * Move option block style classnames to parent wrapper on frontend * Make option label font weight inherited from parent block wrapper, add some back compat for default css styles * Fix tests * Move option styles to parent block level element * Forms: remove color gradients block supports (#43427) * Forms: Update gradient property naming in contact form block and tests to ensure consistency * Forms: Update gradient property naming to 'gradients' for consistency in input and option blocks * Fix label typo --------- Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com> * [WIP] Forms: migrate Outlined form style for inner block based fields (#43327) * first commit * backend mania * Removing dividing two top of label. Can reinstate * fix number conversion * Match legacy form behaviour when deriving px values for CSS vars * color, typography * Adjust clip path to cater for 1px borders * Implement outline style support for form fields by integrating useFormStyleOutlineClassesAndStyles hook across various blocks. Update CSS variables and styles for outlined and animated form styles in the contact form backend and frontend components. * Cannot fix overlap right now * Trying to fix select, options, etc * desperately trying to assign the right values to css vars * get background working * path to syncing options * use lodash for merging * global styles specificity * Remove isSynced from hook and related code * Try only using hook on label * Inject CSS vars for input as well as label so that it can calculate correct padding * Call it a jetpack contact form notch width * Fix overflowing background when a narrow border-width is set * Fix input block placeholders not selectable/visible when outlined style is active * Fix animated style label and input offset * Animated style: fix label and input offset when using distinct border left style in editor * Fix trailing notch background color * Inputs should take border radius styles so they match the notched border. Fix global style derivation for borders * Fix incorrect block names Co-authored-by: Ramon <ramonjd@users.noreply.github.com> * Improve support for split border radii in outlined form style * Remove min width for notch * This commit syncs jetpack/options with jetpack/input * abstract get inner block hook * esc notched attrs * Check $legacy values before assignment * move css vars to inner elems * Apply the background to the notch elements again instead of the input to ensure border aligns with background. Remove the z-index rule so that the input/placeholder is visible and can be edited * Adding padding where there's a border Enhance contact form styles and structure by adding support for animated styles, adjusting border colors, and refining fieldset rendering logic. * Add filler notch element on frontend * Fix flex shrink/grow of notch elements with new filler notch element * Limit padding of inputs to support a wider range of border radii units This helps prevent situations where the calculated padding can end up being a huge number when units like % are used. 100% might make sense for a border radius, but that value used for a padding is huge. Cap the padding at 100px to match trunk's max border radius value. * Ensure dropdowns have same styles for input as other fields, DRY up * Updated rendering logic in the contact form fields to differentiate between outlined and animated styles. Introduced a new helper function to manage outlined style attributes and adjusted CSS to ensure proper styling for outlined fields. Cleaned up related code for clarity and maintainability. * Ensure default padding for outlined styles in inputs * Refactor contact form styles to ensure global styles can override default border and padding settings. Updated class logic for option groups to conditionally apply border styles based on attributes, enhancing flexibility and maintainability. * Account for split border radius when calculating css var on the frontend * Set a max width for any elements using --jetpack--contact-form--notch-width of 100px * Update tests with new shortcode attributes and styles for outline and options * Switch inputs and labels for the outlined and animated style so that label is above input * Remove background on inputs for outlined style, background is being applied to labels instead * Add filler notch element to match editor styles * Add max-width for trailing notch element * Fix border radius css var not picking up single values with a unit * Remove border radius and clip path on inputs for outlined style (border radius is applied on the label, clip path does nothing) * Update tests with new attributes and outline HTML * Default white background in the editor * Ensure the Button variation on the Multiple Choice (Checkbox) block inherits the current color from the option block. * Add background color support for outlined style in contact form inputs and update related tests * Fix outlined border radius for checkbox multiple * Fix css border-radius var calculation * Fix checkbox multiple radius for outlined style * Small tidy up * Enhance outline styles handling in contact form fields by adding form style parameter and refining border radius calculations. Update CSS to include z-index for animated labels. * Apply outlined border radius style to radio fields to match other fields * Remove spaces in inline styles * Select arrow position, default padding for has-background * Padding magic on the options in outlined * Add font size adjustment for legend in outlined contact form style * Fix position of legend and right padding for options * Remove export of constant * Combine is_outlined `if` statements for checkbox multiple * Combine is_outlined `if` statements for radio * Rename useFormStyleOutlineClassesAndStyles to useVariationStyleProperties * Only memoize based on changes to block type when merging global styles * Add documentation to useVariationStyleProperties * Small tidy up, rename a function and add docs * Remove commented out css declarations * Remove dead code. Context is unused. Anywhere. Go look if you don't believe me. --------- Co-authored-by: Daniel Richards <daniel.richards@automattic.com> * Add esc_attr calls to render_radio_field (#43488) * Reinstate default padding where there's a border. Add option chaining to innerBlock look up as trunk forms won't have it. * Use correct block name in get_ouline_styles (#43489) * Forms: standardize animated variation style paddings (#43469) * Update padding for animated style * Fix updated function * Rename get_outline_styles * check borderradius * Calculate border widths with all sides via CSS vars * Fix text area top position * Reinstate default (trunk) padding for animated labels etc * Default value of null on border sizes * Remove dupe CSS * JS Doc :success: * Add legacy CSS var as default * Use the `borderwidth` field attribute as the legacy legacy border width value * Explain use of `borderwidth` value * Update projects/packages/forms/src/contact-form/class-contact-form-field.php Use var `$border_width_attribute` * Add bottom width CSS var to backend, and use border sides in the notched CSS * Remove styles that we're overriding * Switch from !empty to isset for legacy borderwidth attribute check * Do empty/zero check on legacy border widths --------- Co-authored-by: Daniel Richards <daniel.richards@automattic.com> * Forms: Fix block instance border color not overriding global styles border color with outlined style active (on the frontend) (#43532) * Allow block instance border color to override global styles border color * Remove extra space in class name * Revert input + option syncing. Bad! * Forms: Fix typography input styles applying to labels when outline style is active (on frontend) (#43534) * Fix rogue typography attributes from input applying to label * Fix bad rebase * Update tests * For classic themes, do not destructure theme config objects that don't exist. * Forms: Fix custom classnames support in inner blocks migration (#43564) * Forms: fix custom class handling in contact form plugin (#43587) * Forms: Enhance class handling in contact form plugin and tests - Updated class handling in `class-contact-form-plugin.php` to filter empty block style classes. - Modified test cases in `Contact_Form_Plugin_Test.php` and `Contact_Form_Test.php` to include additional attributes and ensure proper class wrapping for various field types. - Improved assertions to validate class attributes in rendered output. * Make innerblocks optional. Just for linting * Forms: Fix outline style label font size (#43590) * Fix text input-style field label font size when outlined style is active. * Remove scaling using variable * Fix scaling of multiple option fields when using outlined style * Tidy up styles * Wrap labels * Fix outlined label font size and animation * Fix animation by ensuring top is a valid value * Remove will-change: transform on frontend too. Transform usually does not change. * Forms: fix inconsistent weights in outline style and terms labels (#43545) * Ensure that existing font-weight styles do not override block and global label styles. * Consent weights * Revert options positioning kram * Increase specificity to 0 1 0 for classic themes * Bump specificity of consent label * Bump specificity * Forms: Fix animated style label font scaling (#43615) * Fix animated style label font size in editor * Add span wrapper around label text * Update animated label styles on frontend * Size and animation adjustments for required text * Fix label animating when selected in editor if using the animated form style variation and no placeholder is set * Forms Fix animated label centered positioning (#43635) * Fix animated label vertical centering when using uneven borders in the input * Remove unused cass var * Forms: Remove options text color support (#43612) * Remove text color support for jetpack/options, since frontend does not replicate the markup of the editor and so style parity cannot be achieved * Try to fix tests * Whoops, wrong flag * One more time --------- Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com> * Forms: options block layout tweaks (#43531) * Refactor contact form styles and rendering logic to enhance alignment and maintainability. Update CSS for radio and checkbox options to use consistent alignment, and streamline fieldset and div class attributes by removing unnecessary prefixes. Improve handling of border styles and attributes for outlined forms, ensuring compatibility with global styles. * Try baseline for the options * Revert changes to "fix" option alignment * Revert option alignment v2 * Add classes to tests * Reinstate tweaks for option positioning * Apply wp-block-jetpack-option class in the attribute migration method * Use em instead of rem. Remove unnecessary tweaks * Border support for classic themes * Ensure radio inputs don't warp in classic themes. Update options description * Force opinionated dimensions on the options inputs * wp-block-jetpack-option was not being applied to inner options blocks * Forms: update padding for jetpack options in contact form to conform with trunk (#43634) * consolidate legends * Remove styles that are inconsistent with existing trunk spacing. (frontend) * Remove padding in editor * editor * The feature branch has different markup for .wp-block-jetpack-options so we need to target the fieldset using different selectors * comments * Fix date field label suffix font size for outlined/animated styles * Fix option input color not inherited in editor * Forms: Update border radius and width handling in deprecateFieldStyles function (#43653) * Attempt to fix warnings about PhanUndeclaredTypeParameter for WP_Block * Forms: Update border radius and width handling in deprecateFieldStyles function * Ensure border radius and width are correctly set to 'undefined' only when they are not provided or are null, allowing for proper handling of zero values. * Coerce lineheight to str * REvert - bad rebase * Update class-contact-form-plugin.php My IDE auto formatted this --------- Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com> * Remove duplicated styles * Form: fix default fallbacks for unmigrated forms (#43676) * Outlined multi option backgrounds defaults * Don't concat the label and option styles for consent and single option in unmigrated forms * PHPCS warning - Use statements are not alphabetically sorted (MediaWiki.Classes.UnsortedUseStatements.UnsortedUse * Forms: tame select arrow positioning (#43674) * initial commit - adding extra markup to the select rendering and fixing positioning of labels * uncommenting * Remove default select border * Update select field rendering to include a wrapper div with the correct class structure for improved styling and consistency in tests. * Update contact form styles to inherit text color and adjust z-index for select wrapper elements * Only run `getAttribute` on select wrapper if there is one * Reinstate padding change * phan me * phanos * whitespace * Ensure that animated labels sit above active input elements. * Forms: account for missing placeholder when transforming input fields to select dropdown and fix z-index (#43721) * Enhance select field transformation by adding default placeholder for input block. Update contact form plugin to correctly reference placeholder attribute. Adjust z-index values in CSS for improved label positioning. * Update z-index values in contact form CSS for improved label positioning and remove redundant styles for outlined fields. * Complete CSS comment * Refactor select field transformation to set placeholder attribute directly from attributes. Remove redundant placeholder handling in inner block creation. * Revert createTextFieldInnerBlocks * Revert experiment. Add default placeholder for select in createTextFieldInnerBlocks * Don't mutate the attributes object * Don't spread optional chaining just in case * Update contact form styles to prevent color overrides by global styles. Add 'color: unset !important;' to both editor.scss and grunion.css for consistent input appearance. (#43737) * Fix consent field spacing between checkbox and label (#43743) * Update context types to use kebab casing (#43740) * Forms: Fix required form field validation for options blocks in the inner blocks refactor (#43738) * Update accessible form selectors for single/multiple choice fields (#43760) * Forms: refactor placeholder handling for outlined and styled forms (#43759) * Forms: Refactor placeholder handling in contact form fields * Simplify placeholder logic to ensure consistent rendering of input fields. * Remove unnecessary conditionals for placeholder assignment and improve code clarity. * Forms: Update contact form styles and placeholder handling * Adjusted placeholder logic to ensure it only renders when a value is present, improving input field consistency. * Updated the contact form stylesheet to include a version query string for better cache management. * Commented out specific CSS rules to prevent unintended side effects related to placeholder visibility in outlined and animated label styles. * Remove other :not(:placeholder-shown) styles * Remove multiple changelogs for branches that were never merged to trunk --------- Co-authored-by: Ramon <ramonjd@users.noreply.github.com> Co-authored-by: Daniel Richards <daniel.richards@automattic.com> Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com> Co-authored-by: Ramon <ramonjd@gmail.com>


Note - this PR merges into #42890 rather than trunk.
Part of JETPACK-277
Follow on from #43125 (which updated the editor styles)
Proposed changes:
Updates the frontend (grunion.css) styles for form fields lowering specificity to 0-1-0 where needed so that global styles can override the CSS.
Note: this doesn't cover the animated or outlined form style variations, only the default styles.
Other information:
Does this pull request change what data or activity we track or use?
No
Testing instructions:
The first thing is to check that this PR doesn't modify the default styles of blocks when compared to trunk.
Next, update the theme.json file for your active theme to add styles for option, label, and input blocks. Here's a little code snippet to get you started, but you should try every possible style property (colors and typography for the label and option. Colors, typography and border for inputs). Add this to the
styles.blocksproperty in the theme.json and then tinker, refresh your editor to check that the styles apply consistenty to all fields:Click here to view snippet
Next, using the site editor, modify the global styles for these blocks and check that the changes apply consistently to every field.
Finally modify the styles on the block instances themselves and check that the styles apply consistently.