spacedmonkey / wp-rest-blocks

Add gutenberg blocks data into post / page / widget REST API endpoints.

Home Page:https://wordpress.org/plugins/rest-api-blocks/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

core/pullquote: `mainColor` is only used if `className = "is-style-solid-color"` and `customTextColor` is not used

lagset opened this issue · comments

Description

When setting the the "Main Color" of a core/pullquote-block instance in the editor by choosing a color of the color palette the mainColor attribute provided by the restAPI is not populated as expected:

It is only used if className = "is-style-solid-color" and customTextColor is not used. Otherwise the attribute customMainColor is used and populated with the hex-value of the chosen palette color.

Since the information is provided by the customMainColor attribute this is not a severe problem, but still seems inconsisent.

Examples

Not as expected: restAPI result for a core/pullquote block with "Style" set to "Default" and "Main Color" set to a palette preset with the slug "primary":

show result
{
  "blockName": "core/pullquote",
  "attrs": {
    "customMainColor": "#00aaad",
    "className": "has-background is-style-default",
    "value": "<p>is-style-default</p><cite>main color by Block Color Palettes</cite>",
    "citation": "main color by Block Color Palettes",
    "mainColor": "",
    "textColor": "",
    "customTextColor": "",
    "align": "",
    "anchor": ""
  },

As expected: restAPI result for a core/pullquote block with "Style" set to "Solid Color" and "Main Color" set to a palette preset with the slug primary:

show result
{
  "blockName": "core/pullquote",
  "attrs": {
    "mainColor": "primary",
    "className": "has-background is-style-solid-color",
    "value": "<p>is-style-solid-color</p><cite>main color by Block Color Palettes</cite>",
    "citation": "main color by Block Color Palettes",
    "customMainColor": "",
    "textColor": "",
    "customTextColor": "",
    "align": "",
    "anchor": ""
  },

As expected: restAPI result for a core/pullquote block with "Style" set to "Solid Color", "Main Color" set to a palette preset with the slug "primary" and "Text Color" set to a palette preset with the slug secondary:

show result
{
  "blockName": "core/pullquote",
  "attrs": {
    "mainColor": "primary",
    "textColor": "secondary",
    "className": "has-background is-style-solid-color",
    "value": "<p>is-style-solid-color</p><cite>main color and text color by Block Color Palettes</cite>",
    "citation": "main color and text color by Block Color Palettes",
    "customMainColor": "",
    "customTextColor": "",
    "align": "",
    "anchor": ""
},

Not as expected: restAPI result for a core/pullquote block with "Style" set to "Solid Color", "Main Color" set to a palette preset with the slug "primary" and "Text Color" set to a custom color with the hex code #0008ff:

show result
{
  "blockName": "core/pullquote",
  "attrs": {
    "customMainColor": "#00aaad",
    "customTextColor": "#0008ff",
    "className": "has-background is-style-solid-color",
    "value": "<p>is-style-solid-color</p><cite>main color by Block COlor Palettes and text Color Custom</cite>",
    "citation": "main color by Block COlor Palettes and text Color Custom",
    "mainColor": "",
    "textColor": "",
    "align": "",
    "anchor": ""
  },

Expected Behaviour

When setting the "Main Color" of a core/pullquote-block instance in the editor by choosing a color of the color palette, the attribute mainColor should be populated with the slug of the chosen palette color, no matter which other attributes are set for the block instance.