WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.57k stars 4.22k forks source link

When a template part is inside a template part, it is not possible to clear customizations in the Site Editor #41081

Open carolinan opened 2 years ago

carolinan commented 2 years ago

Description

In Twenty Twenty-Two, the default header uses a template part ("header") inside another header template part ("header, dark, small"). If you make a change to the inner template part, the "clear customization" option is not available in the template options modal at the top center of the page.

Step-by-step reproduction instructions

  1. Activate Twenty Twenty-Two
  2. Open the site editor (please use the home template)
  3. Open the list view
  4. Select the "Header" template part which is the inner template part in the header: list view showing that the inner template part is selected
  5. Make a change to the part, save
  6. Open the template options modal. You will see that if you hover over the "header" button, it is the outer template part called "Header dark small" that is chosen, not the inner "Header" template part though that is the one you are editing/just selected. Therefor, the "Header" part can not be reset, and you can not see if there are any customizations saved.

Screenshots, screen recording, code snippet

The parent/outer template part is presented in the template details option, not the selected inner template part

Environment info

WordPress 6.0 rc2, with and without current Gutenberg trunk. Beta tester plugin

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

Yes

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

No

talldan commented 2 years ago

That's interesting. I guess Twenty Twenty Two composes headers this way to make things easier, but one of the problems is you end up with two nested HTML <header> elements (technically invalid html).

The inner one shouldn't really be a <header> element. It can be changed to a div in the advanced settings, while still being a Header area.

Another way to structure it would be to have Header (Dark, small) and Header both share a common general template part (which would contain the site logo, site title and navigation).

I don't know if that would solve your issue though, so maybe it needs more thought. I don't know if this menu should list all areas (even when there are multiple headers), or adjust to the selected template part like you suggest.

An alternative might be an option to clear customizations from the block settings menu (though this is getting quite busy): Screen Shot 2022-07-22 at 2 37 14 pm

carolinan commented 2 years ago

For this particular theme it becomes difficult to "un nest" because of the color settings and because changes to the existing template parts, compared to adding new un nested parts, might break existing sites.