Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sidebar styles tab crashes block when theme has >= 8 spacing values #64270

Closed
2 tasks done
ryelle opened this issue Aug 5, 2024 · 5 comments · Fixed by #64284
Closed
2 tasks done

Sidebar styles tab crashes block when theme has >= 8 spacing values #64270

ryelle opened this issue Aug 5, 2024 · 5 comments · Fixed by #64284
Assignees
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Priority] High Used to indicate top priority items that need quick attention [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@ryelle
Copy link
Contributor

ryelle commented Aug 5, 2024

Description

Multiple blocks crash ("This block has encountered an error and cannot be previewed.") when clicking on the "styles" tab in the post editor, when the current theme has >= 8 spacing values.

The console is full of errors like:

Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check the render method of `SpacingInputControl`.

Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check the render method of `SpacingInputControl`.

Step-by-step reproduction instructions

  1. With a theme with 8+ values in settings.spacing.spacingSizes in theme.json
  2. Create or edit a post
  3. Add a group, or buttons, or anything with dimension controls
  4. Click the "styles" tab in the sidebar
  5. The block crashes

Blocks with the dimension control just in the sidebar (no tabs), like Quote, just crash immediately on adding.

Screenshots, screen recording, code snippet

I tested this with the emptytheme theme in gutenberg, updating the theme.json to the following to give me 8 spacing values.

theme.json
{
	"$schema": "../../schemas/json/theme.json",
	"version": 3,
	"settings": {
		"appearanceTools": true,
		"layout": {
			"contentSize": "840px",
			"wideSize": "1100px"
		},
		"spacing": {
			"spacingSizes": [
				{
					"name": "1",
					"size": "10px",
					"slug": "10"
				},
				{
					"name": "2",
					"size": "20px",
					"slug": "20"
				},
				{
					"name": "3",
					"size": "30px",
					"slug": "30"
				},
				{
					"name": "4",
					"size": "40px",
					"slug": "40"
				},
				{
					"name": "5",
					"size": "50px",
					"slug": "50"
				},
				{
					"name": "6",
					"size": "60px",
					"slug": "60"
				},
				{
					"name": "7",
					"size": "70px",
					"slug": "70"
				},
				{
					"name": "8",
					"size": "80px",
					"slug": "80"
				}
			]
		}
	},
	"customTemplates": [
		{
			"name": "custom-template",
			"title": "Custom",
			"postTypes": [ "post" ]
		}
	],
	"patterns": [ "short-text-surrounded-by-round-images", "partner-logos" ]
}

The issue seems to be when it tries to fall back to the select control, when there are too many values for the range slider.

Environment info

  • WP trunk
  • Gutenberg 18.9 (works on 18.8 & below)
  • I've reproduced on Firefox & Chrome on Mac.

Initially reported to me on wordpress.org here WordPress/wporg-main-2022#433 (comment), and https://core.trac.wordpress.org/ticket/61820

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes
@ndiego
Copy link
Member

ndiego commented Aug 5, 2024

I can confirm using TT4. You just need to modify the theme.json file to add two more spacing levels.

@ndiego ndiego added the Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json label Aug 5, 2024
@ndiego
Copy link
Member

ndiego commented Aug 5, 2024

@aaronrobertshaw @andrewserong @t-hamano figured one of you might know what's causing this in 18.9. Any ideas? 😅

@mtias mtias added the [Priority] High Used to indicate top priority items that need quick attention label Aug 5, 2024
@ramonjd
Copy link
Member

ramonjd commented Aug 5, 2024

This smells like a module import issue. I'll see if I can track it down.

@ramonjd
Copy link
Member

ramonjd commented Aug 5, 2024

Also this line:

Bumping that will remove the error. So I think there's a condition that relies on the max value to render a component that can't handle the incoming props.

Or something.

Edit: Not sure if the Legacy component was ever exported again #63190

@ramonjd
Copy link
Member

ramonjd commented Aug 6, 2024

So I think #63258 removed the custom legacy component that the spacing sizes component relied on when there were >= 8 sizes.

I have a fix up here:

cc @ciampo for confirmation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Priority] High Used to indicate top priority items that need quick attention [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants