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 patterns with template type: Index do not load on the index template #54776

Open
carolinan opened this issue Sep 25, 2023 · 2 comments · May be fixed by #54817
Open

Block patterns with template type: Index do not load on the index template #54776

carolinan opened this issue Sep 25, 2023 · 2 comments · May be fixed by #54817
Assignees
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Feature] Templates API Related to API powering block template functionality in the Site Editor [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@carolinan
Copy link
Contributor

carolinan commented Sep 25, 2023

Description

Block patterns have a parameter called template type. A template type is, for example, a page or archive.
Patterns with this parameter are meant to be available when you:

  • Create a new template of that type
  • Open an existing template of that type that has no content (you can delete all the existing blocks, save and refresh).

But block patterns with the template type index do not show in the pattern selection modal when you are editing the index.

Step-by-step reproduction instructions

You can test this with the theme Twenty Twenty-four, downloadable at https://github.com/WordPress/twentytwentyfour

Delete the home.html template in the theme folder.
Open the Site Editor, and open the index template.
Delete all blocks. Save.
Reload the editor.
Confirm that no pattern selection modal shows.

Expected: There should be two patterns available.

Screenshots, screen recording, code snippet

No response

Environment info

Current 6.4 nightly through the beta tester plugin
Current Gutenberg trunk

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

@carolinan carolinan changed the title Block patterns with template type: Index do not load in the index. Block patterns with template type: Index do not load on the index template Sep 25, 2023
@carolinan carolinan added [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Type] Bug An existing feature does not function as intended labels Sep 25, 2023
@aaronrobertshaw
Copy link
Contributor

aaronrobertshaw commented Sep 26, 2023

Thanks for submitting this issue @carolinan 👍

I'm struggling to find exactly when the expected behaviour was broken. This isn't an area I'm familiar with unfortunately.

From my digging so far, this doesn't appear to be a patterns issue directly, it seems more related to templates.

The start modal that displays the patterns will only render when there is fallback template content. You can find that check in the code here. The hook that retrieves that fallback content involves an API request, which for me always seems to return an empty string for an index template. It doesn't for other template types.

If I fudge the StartModal code to ignore if there is fallback content or not the modal appears with the expected block patterns.

Screenshot 2023-09-26 at 5 27 43 pm

There are a couple of related PRs that might help further investigations. #51477 apparently broke the template lookup API but that was resolved in #54599. Perhaps there is something else needed in that direction?

cc/ @ntsekouras @scruffian who might have more expertise here 🤞

@aaronrobertshaw aaronrobertshaw added [Feature] Templates API Related to API powering block template functionality in the Site Editor and removed [Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced labels Sep 26, 2023
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Sep 26, 2023
@kevin940726
Copy link
Member

I have a PR up in #54817. I'm not sure if I'm understanding the problem correctly though. Seems like there's a race here which I don't know if it's expected. If we manually delete all the content in a template and save it, then naturally it can't be used as a fallback content. Ironically, this is also when we want to show the start modal for the users.

Perhaps the problem lies in the check where we always expect the fallback content to be present. I don't have any historical knowledge as to why we need that check though. If we could remove it then the fix could be simpler I guess 🤔. I'll leave the decision to someone more knowledgeable than me on this aspect.

@bph bph moved this to In Progress in WordPress 6.4 Editor Tasks Sep 28, 2023
@bph bph moved this from In Progress to Punted to 6.5 in WordPress 6.4 Editor Tasks Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Feature] Templates API Related to API powering block template functionality in the Site Editor [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
No open projects
Status: Punted to 6.5
Development

Successfully merging a pull request may close this issue.

3 participants