Make WordPress Core

Opened 3 weeks ago

Closed 3 weeks ago

#61589 closed defect (bug) (fixed)

Fix: Block style variations containing ref values

Reported by: aaronrobertshaw's profile aaronrobertshaw Owned by: ellatrix's profile ellatrix
Milestone: 6.6 Priority: normal
Severity: normal Version: 6.6
Component: Editor Keywords: gutenberg-merge has-patch has-unit-tests dev-reviewed
Focuses: Cc:

Description

This ticket tracks the backporting of PHP files for the following Gutenberg updates:

These changes fix an issue where block style variations that use ref values to reference styles elsewhere in theme.json weren't working.

Change History (6)

This ticket was mentioned in PR #6989 on WordPress/wordpress-develop by @aaronrobertshaw.


3 weeks ago
#1

  • Keywords has-patch has-unit-tests added

This PR backports the fix from:

This restores the ability to reference style values from elsewhere within theme.json for block style variations.

Trac ticket: https://core.trac.wordpress.org/ticket/61589#ticket

#### Test Instructions

  1. Add some ref values for block style variations to your theme.json e.g. update TT4 with the sections from the theme.json snippet below
  2. Load the site editor and edit the default home page
  3. Confirm that outline buttons are displayed and have the correct referenced style values
  4. Save and ensure the same on the frontend

<details>
<summary>Example theme.json snippet</summary>

{
    "styles": {
        "elements": {
            "button": {
                "border": {
                    "color": "transparent",
                    "radius": "0.25em",
                    "style": "solid",
                    "width": "1px"
                },
                "color": {
                    "background": "var(--wp--preset--color--accent)",
                    "text": "var(--wp--preset--color--base)"
                },
                "spacing": {
                    "padding": {
                        "bottom": "0.5em",
                        "left": "1.25em",
                        "right": "1.25em",
                        "top": "0.5em"
                    }
                }
            }
        },
        "blocks": {
            "core/button": {
                "border": {
                    "color": { "ref": "styles.elements.button.border.color" },
                    "radius": { "ref": "styles.elements.button.border.radius" },
                    "style": { "ref": "styles.elements.button.border.style" },
                    "width": { "ref": "styles.elements.button.border.width" }
                },
                "color": {
                    "background": { "ref": "styles.elements.button.color.background" },
                    "text": { "ref": "styles.elements.button.color.text" }
                },
                "spacing": {
                    "padding": {
                        "bottom": { "ref": "styles.elements.button.spacing.padding.bottom" },
                        "left": { "ref": "styles.elements.button.spacing.padding.left" },
                        "right": { "ref": "styles.elements.button.spacing.padding.right" },
                        "top": { "ref": "styles.elements.button.spacing.padding.top" }
                    }
                },
                "variations": {
                    "outline": {
                        "border": {
                            "color": "currentColor",
                            "width": { "ref": "styles.elements.button.border.width" }
                        },
                        "color": {
                            "text": { "ref": "styles.elements.button.color.background" }
                        },
                        "spacing": {
                            "padding": {
                                "bottom": { "ref": "styles.elements.button.spacing.padding.bottom" },
                                "left": { "ref": "styles.elements.button.spacing.padding.left" },
                                "right": { "ref": "styles.elements.button.spacing.padding.right" },
                                "top": { "ref": "styles.elements.button.spacing.padding.top" },
                            }
                        }
                    }
                }
            }
        }
    }
}

</details>

## Screenshots or screencast

Before After
https://github.com/WordPress/wordpress-develop/assets/60436221/7452177d-d238-4be7-adb1-29a5e43370a5 https://github.com/WordPress/wordpress-develop/assets/60436221/04bd42db-5da5-4fa7-9c73-5e111b59191b

#2 @ellatrix
3 weeks ago

  • Owner set to ellatrix
  • Resolution set to fixed
  • Status changed from new to closed

In 58690:

Section Styles: Prevent flash of variation style updates.

This is fixed by preloading the styles.

Fixes #61589.
Fixes https://github.com/WordPress/wordpress-develop/pull/6989.
See https://github.com/WordPress/gutenberg/pull/63172.

Props aaronrobertshaw, andrewserong, ramonopoly.

#3 @ellatrix
3 weeks ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Apologies, I got confused between the tickets. [58690] fixed #61553, not this ticket.

#4 @ellatrix
3 weeks ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 58691:

Section Styles: Fix ref values within block style variations.

Fixes #61589.
Fixes https://github.com/WordPress/wordpress-develop/pull/6989.
See https://github.com/WordPress/gutenberg/pull/63172.

Props aaronrobertshaw, andrewserong, ramonopoly.

#5 @audrasjb
3 weeks ago

  • Keywords dev-reviewed added
  • Resolution fixed deleted
  • Status changed from closed to reopened

This changeset looks good to me. This is a second committer sign-off. Marking as dev-reviewed.

#6 @hellofromTonya
3 weeks ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 58699:

Editor: Fix ref values within block style variations.

Fixes an issue where block style variations that use ref values to reference styles elsewhere in theme.json weren't working.

Retrieves reference values when generating styles for block style variations. How? When retrieving variation data, to generate styles from, also retrieve any referenced values.

Reviewed by audrasjb.
Merges [58691] to the 6.6 branch.

Props aaronrobertshaw, andrewserong, ramonopoly.
Fixes #61589.

Note: See TracTickets for help on using tickets.