Site Editor: simplify sidebar for Pages & Templates#76868
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Pull request overview
Simplifies Pages/Templates sidebar generation in the site editor by consolidating DataViews sidebar rendering into a single component that can be customized via an icon resolver.
Changes:
- Refactors
DataViewsSidebarContentto renderSidebarNavigationItemdirectly and accept aresolveIcon(view)callback. - Updates the legacy Templates sidebar content to reuse
DataViewsSidebarContentwith a templates-specific icon resolver. - Removes the now-obsolete
DataViewItemcomponent and its related styling.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/content-legacy.js |
Reuses DataViewsSidebarContent for templates and injects a custom icon resolver. |
packages/edit-site/src/components/sidebar-dataviews/index.js |
Centralizes sidebar item rendering and adds resolveIcon extensibility. |
packages/edit-site/src/components/sidebar-dataviews/style.scss |
Removes styles tied to the deleted DataViewItem wrapper. |
packages/edit-site/src/components/sidebar-dataviews/dataview-item.js |
Deletes the legacy wrapper component in favor of direct SidebarNavigationItem usage. |
Comments suppressed due to low confidence (1)
packages/edit-site/src/components/sidebar-dataviews/index.js:51
postTypeis checked only after callinguseViewConfig({ name: postType }). IfpostTypeis ever falsy, this can still trigger the core-data resolver and request/wp/v2/view-config?kind=postType&name=undefined, even though the component returnsnullafterwards. Consider makingpostTypea required prop (and removing this guard), or ensuring the hook is called with a stable validnamethat won’t cause an invalid fetch whenpostTypeis missing.
const { view_list: viewList } = useViewConfig( {
kind: 'postType',
name: postType,
} );
if ( ! postType ) {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/content-legacy.js
Outdated
Show resolved
Hide resolved
|
Size Change: -385 B (0%) Total Size: 7.73 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in fc69eac. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23658603330
|
Part of #76544
What?
Simplifies the generation of the sidebar for Pages and Templates in site editor.
Why?
Over at #76544 we're working on generalizing sidebars, so they can be created automatically from configuration. This is a step more in that simplification.
How?
SidebarDataViewscomponent for clarity and to accept a function to resolve the icon.DataviewsTemplatesSidebarContentcomponent to reuse theSidebarDataViewsone.Testing Instructions
The sidebar for Pages & Templates should look the same.
Use of AI Tools
This PR was curated manually.