Skip to content

WIP Fix/dropdown field arrow border overlap - #43673

Closed
ramonjd wants to merge 88 commits into
update/migrate-form-fields-to-inner-blocksfrom
fix/dropdown-field-arrow-border-overlap
Closed

ramonjd wants to merge 88 commits into
update/migrate-form-fields-to-inner-blocksfrom
fix/dropdown-field-arrow-border-overlap

Conversation

@ramonjd

@ramonjd ramonjd commented May 29, 2025

Copy link
Copy Markdown
Member

Fixes #

Proposed changes:

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

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

Testing instructions:

  • Go to '..'

aaronrobertshaw and others added 30 commits May 16, 2025 14:16
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.
- 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.
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.
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.
Co-authored-by: Ramon <ramonjd@users.noreply.github.com>
* 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>
…43027)

* Forms: Fix error thrown in previews for synced form fields

* Clean up

* Rename the context type stuff
…ne 'class' attribute on the extra_attrs array
ramonjd and others added 19 commits May 16, 2025 14:21
…#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>
… to innerBlock look up as trunk forms won't have it.
* 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>
…order 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
…yle is active (on frontend) (#43534)

* Fix rogue typography attributes from input applying to label

* Fix bad rebase

* Update tests
* 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
* 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.
…3545)

* 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
* 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
* Fix animated label vertical centering when using uneven borders in the input

* Remove unused cass var
* 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>
* 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
…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
@github-actions github-actions Bot added [Block] Form Form block (also see Form package label) [Feature] Forms [Package] Forms [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests labels May 29, 2025
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • 🔴 Add a "[Status]" label (In Progress, Needs Review, ...).
  • 🔴 Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


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 29, 2025
@ramonjd

ramonjd commented May 29, 2025

Copy link
Copy Markdown
Member Author

Moving a combination of this and @ramonjd's work in #43546 to:

@ramonjd ramonjd closed this May 29, 2025
@github-actions github-actions Bot removed 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 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Form Form block (also see Form package label) [Feature] Forms [Package] Forms [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants