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

Block Widget Editor: Widget area layout is broken #54295

Closed
t-hamano opened this issue Sep 8, 2023 · 3 comments · Fixed by #54372
Closed

Block Widget Editor: Widget area layout is broken #54295

t-hamano opened this issue Sep 8, 2023 · 3 comments · Fixed by #54372
Labels
[Package] Edit Widgets /packages/edit-widgets [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release

Comments

@t-hamano
Copy link
Contributor

t-hamano commented Sep 8, 2023

Description

The latest Gutenberg seems to have the following problems with the layout in the block widget editor.

The widget area is narrow and there is spacing around the widget area

gb_enabled_open

Closing the widget area results in an extremely narrow width

285631b9a83010126b06c141cfac4fba.mp4

Expected behavior (Gutenberg plugin disabled)

gb_disabled

Step-by-step reproduction instructions

  • Activate Twenty Twenty One theme
  • Go to Appearance > Widgets

Screenshots, screen recording, code snippet

No response

Environment info

No response

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

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release [Package] Edit Widgets /packages/edit-widgets labels Sep 8, 2023
@t-hamano
Copy link
Contributor Author

t-hamano commented Sep 8, 2023

According to my research, I think this is caused by a slight change in the structure of the Widget Editor due to #54149.

@t-hamano
Copy link
Contributor Author

With #54149, the widget editor is now rendered via the new BlockCanvas component. This component has a WritingFlow component with the .editor-style-wrapper class applied inside it.

However, the widget editor did not originally apply this class to the WritingFlow component. Because this class should be applied to the content wrapper inside each widget area.

If the entire editor has this class, you will end up with unintended style overrides. For example, if a classic theme that supports widgets defines the following theme.json, the style will also be applied to the panel title of the widget area. This is because the widget area panel title is also an h2 element, so it matches the .editor-styles-wrapper h2 selector.

{
	"version": 2,
	"styles": {
		"elements": {
			"h2": {
				"border": {
					"top": {
						"color": "#ff0000",
						"style": "solid",
						"width": "100px"
					}
				}
			}
		}
	}
}

It seems a bit unreasonable to assume all these cases and override the unintended style on the widget editor side. Therefore, I believe that a means to solve this problem by not giving fixed class names to the WritingFlow component is needed first.

@youknowriad

For example, would it be possible to add something like writingFlowProps to the BlockCanvas component? The default value is an object like {className:'editor-styles-wrapper'}, and the approach is to provide a means to override this.

@youknowriad
Copy link
Contributor

For me, it's the widgets editor that has a completely weird behavior. (styles not applied to the whole editor). In an ideal world, the widgets editor would render a separate editor per widget area. I guess there's some reason for the current approach, so in order to avoid regressions let's just avoid using BlockCanvas and restore the previous components.

I don't think we should pollute BlockCanvas with props to address the specifics of the widgets editor because it's such an edge case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Edit Widgets /packages/edit-widgets [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants