gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Template name does not display properly when a theme.json is present

Open emilyatmobtown opened this issue 2 years ago • 4 comments

Description

I expect the page template title to display in the sidebar Summary panel when I select a new custom page template. If I don't have a theme.json in my theme, this works as expected.

If I do have a theme.json in my theme, the template title displays Default template instead of the custom page template title.

This happens if I add a template in the customTemplates array in theme.json – or if I use a classic PHP template and don't include it in a customTemplates array in the theme.json.

Step-by-step reproduction instructions

  1. Add a page template to any theme without using a theme.json.
  2. Create a new post.
  3. In the sidebar Summary panel, click "Default template" and select the custom page template in the modal.
  4. Close the modal and see that the new page template title is displayed instead of "Default template".
  5. Add a basic theme.json to the theme.
  6. Create a new post.
  7. In the sidebar Summary panel, click "Default template" and select the custom page template in the modal.
  8. Close the modal and see that the new page template title is not displayed. See that the template title still says "Default template".

Screenshots, screen recording, code snippet

The page template is selected in the modal, but "Default template" still displays as the template title in the Summary panel. This theme has a theme.json. Screen Shot 2023-01-25 at 12 34 37

Environment info

  • WP 6.1.1, any theme
  • Gutenberg version 14.1

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

emilyatmobtown avatar Jan 25 '23 17:01 emilyatmobtown

Hi! I believe this is a duplicate of https://github.com/WordPress/gutenberg/issues/41449 ?

carolinan avatar Jan 26 '23 07:01 carolinan

Hi! I believe this is a duplicate of #41449 ?

@carolinan No, I believe that's different. It looks like #41449 is a suggestion for UX improvement. This is a bug. The template title displays as expected when there's no theme.json. But when there's a theme.json, the template title displays "Default template" no matter what template is selected.

emilyatmobtown avatar Jan 26 '23 14:01 emilyatmobtown

In the logic, it appears that there's an assumption that, if there's a theme.json, then it's a block theme and therefore using the wp_template post type to store templates. When that's not found, then "Default template" is displayed rather than picking up the template title from the file in the theme or from the theme.json.

emilyatmobtown avatar Jan 26 '23 14:01 emilyatmobtown

Just stumbled upon this issue as well on a production website for a client

corentin-gautier avatar Jan 31 '23 14:01 corentin-gautier