gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Post Excerpt Block: "Read More" styled incorrectly with Global Styles

Open johnstonphilip opened this issue 5 years ago • 2 comments

Description

The Post Excerpt block's "Read More" text is not styled correctly if Global Styles sets a default for the paragraph tag.

Here's a screenshot to help attempt explain: Screen Shot 2021-05-12 at 4 55 32 PM

Step-by-step reproduction instructions

  1. Make an experimental-theme.json file in your theme.
  2. Put this code into it:
{
	"settings": {
		"defaults": {
			"layout": {
				"contentSize": "var(--wp--custom--content--default-width)",
				"wideSize": "var(--wp--custom--content--wide-width)"
			},
			"custom": {
				"typo": {
					"rootSize": 16,
					"adaptiveRatio": 0.8,
					"scale": 1.2,
					"lineHeight": 1.5
				},
				"content": {
					"lineWidth": 74,
					"defaultWidth": "calc((var(--wp--custom--typo--root-size) * 1px + var(--wp--custom--typo--adaptive-ratio) * 1vw) * var(--wp--custom--content--line-width) / 2)",
					"wideWidth": "calc(1.5 * var(--wp--custom--content--default-width))",
					"padding": "1em"
				}
			},
			"color": {
				"palette": [
					{
						"slug": "light",
						"color": "#f5f7f9"
					},
					{
						"slug": "dark",
						"color": "#000"
					}
				],
				"custom": false
			},
			"typography": {
				"fontSizes": [
					{
						"name": "small",
						"slug": "small",
						"size": "calc(var(--wp--preset--font-size--normal) / var(--wp--custom--typo--scale))"
					},
					{
						"name": "Normal",
						"slug": "normal",
						"size": "calc(var(--wp--custom--typo--root-size) * 1px + var(--wp--custom--typo--adaptive-ratio) * 1vw)"
					},
					{
						"name": "Medium",
						"slug": "medium",
						"size": "calc(var(--wp--preset--font-size--normal) * var(--wp--custom--typo--scale))"
					},
					{
						"name": "large",
						"slug": "large",
						"size": "calc(var(--wp--preset--font-size--medium) * var(--wp--custom--typo--scale))"
					},
					{
						"name": "Huge",
						"slug": "huge",
						"size": "calc(var(--wp--preset--font-size--large) * var(--wp--custom--typo--scale))"
					}
				],
				"fontFamilies": [
					{
						"fontFamily": "Public Sans, Helvetica Neue, Helvetica, Arial, sans-serif",
						"slug": "publicsans",
						"name": "Public Sans"
					},
					{
						"fontFamily": "Constantia, \"Lucida Bright\", Lucidabright, \"Lucida Serif\", Lucida, \"DejaVu Serif\", \"Bitstream Vera Serif\", \"Liberation Serif\", Georgia, serif",
						"name": "Serif",
						"slug": "serif"
					},
					{
						"fontFamily": "Consolas, \"Andale Mono WT\", \"Andale Mono\", \"Lucida Console\", \"Lucida Sans Typewriter\", \"DejaVu Sans Mono\", \"Bitstream Vera Sans Mono\", \"Liberation Mono\", \"Nimbus Mono L\", Monaco, \"Courier New\", Courier, monospace",
						"name": "Monospace",
						"slug": "monospace"
					},
					{
						"fontFamily": "Literata, Constantia, \"Lucida Bright\", Lucidabright, \"Lucida Serif\", Lucida, \"DejaVu Serif\", \"Bitstream Vera Serif\", \"Liberation Serif\", Georgia, serif",
						"name": "Literata",
						"slug": "literata"
					}
				],
				"fontStyles": [
					{ "name": "Regular", "slug": "normal", "value": "normal" },
					{ "name": "Italic", "slug": "italic", "value": "italic" }
				],
				"fontWeights": [
					{ "slug": "200", "value": "200", "name": "Thin" },
					{ "slug": "300", "value": "300", "name": "Light" },
					{ "slug": "400", "value": "400", "name": "Regular" },
					{ "slug": "500", "value": "500", "name": "Medium" },
					{ "slug": "600", "value": "600", "name": "Semibold" },
					{ "slug": "700", "value": "700", "name": "Bold" },
					{ "slug": "800", "value": "800", "name": "Heavy" },
					{ "slug": "900", "value": "900", "name": "Black" }
				],
				"textTransforms": [
					{ "name": "AB", "slug": "uppercase" },
					{ "name": "ab", "slug": "lowercase" },
					{ "name": "Ab", "slug": "capitalize" }
				],
				"textDecorations": [
					{ "name": "Underline", "slug": "underline", "value": "underline" },
					{
						"name": "Strikethrough",
						"slug": "strikethrough",
						"value": "line-through"
					}
				],
				"customFontSize": false,
				"customLineHeight": true
			}
		}
	},
	"styles": {
		"root": {
			"color": {
				"background": "var(--wp--preset--color--light)",
				"text": "var(--wp--preset--color--dark)",
				"link": "var(--wp--preset--color--dark)"
			},
			"typography": {
				"fontSize": "var(--wp--preset--font-size--normal)",
				"lineHeight": "var(--wp--custom--line-height--body)",
				"fontFamily": "var(--wp--preset--font-family--system)"
			}
		},
		"core/paragraph": {
			"typography": {
				"fontSize": "var(--wp--preset--font-size--normal)",
				"lineHeight": "var(--wp--custom--typo--line-height)"
			}
		},
		"core/heading/h1": {
			"typography": {
				"fontSize": "var(--wp--preset--font-size--huge)",
				"lineHeight": "calc(var(--wp--custom--typo--line-height) * 0.9)"
			}
		},
		"core/heading/h2": {
			"typography": {
				"fontSize": "var(--wp--preset--font-size--large)",
				"lineHeight": "calc(var(--wp--custom--typo--line-height) * 0.9)"
			}
		},
		"core/heading/h3": {
			"typography": {
				"fontSize": "var(--wp--preset--font-size--medium)",
				"lineHeight": "var(--wp--custom--typo--line-height)"
			}
		},
		"core/heading/h4": {
			"typography": {
				"fontSize": "var(--wp--preset--font-size--normal)",
				"lineHeight": "var(--wp--custom--typo--line-height)"
			}
		},
		"core/heading/h5": {
			"typography": {
				"fontSize": "var(--wp--preset--font-size--small)",
				"lineHeight": "calc(var(--wp--custom--typo--line-height) * 1.16)"
			}
		},
		"core/heading/h6": {
			"typography": {
				"fontSize": "var(--wp--preset--font-size--small)",
				"lineHeight": "calc(var(--wp--custom--typo--line-height) * 1.16)"
			}
		}
	},
	"templateParts": [
		{
			"name": "header",
			"area": "header"
		},
		{
			"name": "footer",
			"area": "footer"
		}
	]
}

  1. Add a Post Excerpt block to the index.html page in the Site Editor.
  2. Set the Font Size in the Post Excerpt block to be small.
  3. Notice the Read More text does not get set to small.

Expected behaviour

All of the text in the Post Excerpt block should get set to match the font size defined in the block.

WordPress information

  • WordPress version: Version 5.7.2
  • Gutenberg version: Version 10.6.0
  • Are all plugins except Gutenberg deactivated? Yes
  • Are you using a default theme: No.

Device information

  • Device: MacbookPro
  • Operating system: MacOS
  • Browser: Chrome 90.0.4430.212

johnstonphilip avatar May 13 '21 15:05 johnstonphilip

I have been able to confirm this. Also when the font size for the excerpt is changed in the editor, the change is not visible on the front, it still uses the size set to the paragraph block in theme.json.

carolinan avatar May 15 '21 04:05 carolinan

I can still reproduce it on trunk: global core/paragraph styles (:root :where(p)) override the typography set on the Post Excerpt block, because the excerpt and "Read more" text are rendered inside <p> elements. I'll open a PR shortly.

Mustafabharmal avatar Oct 07 '26 14:10 Mustafabharmal