-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 - Nav Panel - Only show auto-draft template parts corresponding to current theme. #26948
Site Editor - Nav Panel - Only show auto-draft template parts corresponding to current theme. #26948
Conversation
per_page: -1, | ||
} | ||
); | ||
const currentTheme = select( 'core' ).getCurrentTheme()?.stylesheet; | ||
const themeTemplateParts = select( 'core' ).getEntityRecords( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alternatively, instead of doing 2 queries and combining the results we could do one query to retrieve all publish/auto-drafts and then filter the results to exclude auto drafts of other themes. I wonder which may be a better option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems having the 2 queries here both firing as the site editor starts loading sometimes messes up auto-draft creation and we get a duplicate of each template part supplied by the theme. I would expect changes from #26383 to solve this since auto-drafts will have already been created by this point, but that still leaves the question above - combining 2 queries vs. filtering the results of 1 query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion here, but the current two queries approach makes sense to me assuming that issue gets resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I thought that PR was good to merge but it looks like you pointed out some other bugs with it.
I updated this PR to use the other approach to filter the results of one query instead, and it seems to be working well.
Size Change: +56 B (0%) Total Size: 1.19 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works for me, but it'd be good too make sure that the auto-draft issue is fixed by the other PR before merging!
packages/edit-site/src/components/navigation-sidebar/navigation-panel/menus/template-parts.js
Outdated
Show resolved
Hide resolved
per_page: -1, | ||
} | ||
); | ||
const currentTheme = select( 'core' ).getCurrentTheme()?.stylesheet; | ||
const themeTemplateParts = select( 'core' ).getEntityRecords( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion here, but the current two queries approach makes sense to me assuming that issue gets resolved
Agreed. |
Updated to use one query and filter the results, since the PR that would fix the bugs that happen when combining the two queries looks like it might still need some more time (I previously thought that one was ready to merge). Let me know if this still looks good to you @noahtallen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, works well for me!
Description
As noted in #26402 if you switch themes a few times, auto-drafts of template parts build up and they are all shown in the Nav panel. This PR updates the nav panel to only show auto-drafts that correspond to the currently active theme.
How has this been tested?
Screenshots
Types of changes
Checklist: