Skip to content

Page Inspector Swap Template Functionally has broken the page template hierarchy  #54596

@mikejolley

Description

@mikejolley

Description

This PR merged last week introduced the ability to "swap templates" for pages. However, something in this PR has broken the page template hierarchy, meaning in the site editor only, it claims the "Pages" template is in use, when in fact a custom template exists.

As an example, in this case there is a template called page-cart. This is also registered via the page_template_hierarchy filter to ensure it has priority over all other templates. Before #51477 this is what you would see in the page editor:

Screenshot 2023-09-19 at 12 29 34

After #51477 you can see it now uses the generic "pages" template instead:

Screenshot 2023-09-19 at 12 32 35

Whats more, the preview in the site editor also uses the "pages" template. The frontend views still use page-cart as before.

It seems as though the issues are:

  1. Hierarchy is no longer respected in the site editor
  2. Swap template functionality should not be available if a custom template is in place

Step-by-step reproduction instructions

We're running into this issue with WooCommerce Blocks which includes a cart template which should be the default.

Screenshots, screen recording, code snippet

No response

Environment info

  • Latest Gutenberg from trunk
  • Twenty Twenty Three

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Site EditorRelated to the overarching Site Editor (formerly "full site editing")[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions