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

Site Editor: templates available in sidebar is limited to 10 in total #36563

Closed
Sandstromer opened this issue Nov 17, 2021 · 9 comments · Fixed by #36761
Closed

Site Editor: templates available in sidebar is limited to 10 in total #36563

Sandstromer opened this issue Nov 17, 2021 · 9 comments · Fixed by #36761
Assignees
Labels
[Feature] Navigation Component A navigational waterfall component for hierarchy of items. [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@Sandstromer
Copy link

Description

With a theme that includes more than 10 templates, some of the templates are not available in the Site Editor left sidebar.

It seems to be that the templates are being sorted alphabetically, and all templates after the 10th item are dropped from the sidebar.

An example would be a theme that has the following 12 templates:
404
author
index
page
page-blog
page-contact
page-home
page-no-header
page-no-footer
page
search
single

In this scenario the 'search' and 'single' templates are dropped from the available templates in the sidebar, making them unavailable for editing.

It seems to be limited to a total of 10 templates.

With multiple "page" templates they are grouped in a "Page Templates" sub-panel, but still the last 2 do not appear after the "Page Templates" sub heading.

The sidebar was very recently reverted as a temporary solution in #36516

Step-by-step reproduction instructions

Take any theme e.g. empty theme and copy/rename the page (or single) template multiple times until you have more than 10 templates in total.
Load the Site Editor.
Notice any templates that are ordered alphabetically after the 10th item are missing from the available templates.

Screenshots, screen recording, code snippet

No response

Environment info

WP 5.82
Gutenberg 11.9.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

@Sandstromer
Copy link
Author

Looks like in core-data/index,js the getQueryParts(query) function has the perPage attribute set at 10.

Don't know if increasing this number is something that can done, or we just have to live with some templates not being available for editing.

@Sandstromer
Copy link
Author

Hopefully someone with more knowledge can answer whether increasing this would negatively affect performance elsewhere.

@annezazu annezazu added [Feature] Full Site Editing [Type] Bug An existing feature does not function as intended [Feature] Navigation Component A navigational waterfall component for hierarchy of items. [Status] Needs More Info Follow-up required in order to be actionable. and removed [Type] Bug An existing feature does not function as intended [Status] Needs More Info Follow-up required in order to be actionable. labels Nov 18, 2021
@annezazu
Copy link
Contributor

Apologies for the labeling chaos :D I didn't think I'd have time to test after initially being unable to replicate and then did have time.

I can replicate this and, further, the search functionality shows no results:

template.10.search.mov

@annezazu
Copy link
Contributor

@Copons do you have any insight here since you've done lots of work here? :)

@annezazu
Copy link
Contributor

Removing from 5.9 project since this approach is being worked on for 5.9 and it will resolve this issue by providing a different experience to view all templates: #36379 Still feels wise to address going forward in the navigation component if the full blown component returns in the future.

@Copons
Copy link
Contributor

Copons commented Nov 18, 2021

@annezazu As @Sandstromer said, it's a matter of per_page when fetching the templates for the sidebar.
We originally used per_page: -1, which requests all the templates (expensive, but back then we deemed it reasonable with the assumption that folks might not have hundreds of templates).

That parameter got removed in https://github.com/WordPress/gutenberg/pull/36044/files#r738414102 because, as it turned out:

per_page is not supported in the wp_template and wp_template_part post types.

I'm not exactly sure why it's not supported though. 🤔

@Mamaduka
Copy link
Member

The problem here is that core data limits received items to ten when the per_page argument isn't provided. It is okay for most of the endpoints since they return ten items by default as well. But can cause unexpected behavior likes this for others.

You can find more details in this issue - #15413 (comment).

I think the easiest way to resolve this is to bring back perPage: -1 for template selectors, but in the long term, we should fix #15413.

@youknowriad what do you think?

@youknowriad
Copy link
Contributor

@Mamaduka I agree, I forgot this when I removed the per_page argument from the query, that said when restoring it we should ensure that the right endpoints are preloaded (we might have to update the query string of some preloaded urls)

@Mamaduka
Copy link
Member

Mamaduka commented Nov 19, 2021

we should ensure that the right endpoints are preloaded (we might have to update the query string of some preloaded urls)

Sounds good. I will start working on PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Navigation Component A navigational waterfall component for hierarchy of items. [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants