Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#61589 closed defect (bug) (fixed)

Fix: Block style variations containing ref values

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

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.


2 years 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
2 years ago

  • Owner set to ellatrix
  • Resolution → fixed
  • Status new → 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
2 years ago

  • Resolution fixed
  • Status closed → reopened

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

#4 @ellatrix
2 years ago

  • Resolution → fixed
  • Status reopened → 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
2 years ago

  • Keywords dev-reviewed added
  • Resolution fixed
  • Status closed → reopened

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

#6 @hellofromTonya
2 years ago

  • Resolution → fixed
  • Status reopened → 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.