Navigation: Use the shared list view implementation, not a custom one#75694
Navigation: Use the shared list view implementation, not a custom one#75694
Conversation
|
Size Change: -1.02 kB (-0.01%) Total Size: 6.84 MB
ℹ️ View Unchanged
|
|
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. |
jeryj
left a comment
There was a problem hiding this comment.
Drive by review. Glad we'll rely on the existing list view!
| * @param {Function} props.setInsertedBlock Callback to update inserted block state. | ||
| * @return {Element|null} The additional content or null. | ||
| */ | ||
| export function AdditionalBlockContent( { |
There was a problem hiding this comment.
I think this would be better named as NavigationLinkUI. I think it's only named AdditionalBlockContent because that's the name of the prop it's being passed to?
| @@ -1,304 +0,0 @@ | |||
| /** | |||
There was a problem hiding this comment.
What actually changed from this file? It would make it easier to review if we just exported the things we needed from this file first, then after we feel it's good, do the refactor to split it into different files?
| clientId={ insertedBlock?.clientId } | ||
| link={ insertedBlock?.attributes } | ||
| onBlockInsert={ handleSetInsertedBlock } | ||
| onClose={ () => { |
There was a problem hiding this comment.
Do we need this arrow function here?
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…stViewHeader Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| * @param {string} props.clientId Block client ID. | ||
| * @return {Element} The header component. | ||
| */ | ||
| export default function NavigationListViewHeader( { clientId } ) { |
There was a problem hiding this comment.
It looks like there's a lot of changes here, but really its just that we are sourcing the data from hooks rather than passing it as props.
The NavigationMenuSelector used useEntityProp without an ID, relying on EntityProvider context to resolve the current menu title. After moving the menu selector from MenuInspectorControls (which was wrapped in EntityProvider) to the shared ListViewPanel (which is not), the title was always undefined, causing the "Test Menu" button to never appear. Get the title directly from the navigationMenu entity record already fetched by useNavigationMenu(currentMenuId) instead. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The shared ListViewPanel uses "No items yet." instead of "This Navigation Menu is empty." for the empty state message. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
| const showBlockTitle = isSelectionWithinCurrentSection; | ||
|
|
||
| // Get custom list view configuration from block type | ||
| const listViewConfig = blockType?.listView || {}; |
There was a problem hiding this comment.
Could this also allow a function?
| blockSettingsMenu: LeafMoreMenu, | ||
| additionalBlockContent: NavigationLinkUI, | ||
| panelHeader: NavigationListViewHeader, | ||
| }, |
There was a problem hiding this comment.
I think it might be good to expand the reviewers with it being a new addition to the block API. I'm not sure if there are many settings like this that expand the function of block supports. I'm personally not against the API, but I'm also wondering about the alternatives.
When it comes to the props, blockSettingsMenu and panelHeader both seem fairly obvious and useful.
additionalBlockContent isn't very self-documenting. This is what shows the Link popover when adding a new block. Can it be used for adding other things other than a popover? That's the only one that I think might be worth making private, as it has the potential to break things badly if misused.
With it being a public API, some docs should be added. It might be worth considering stabilizing the same props of PrivateListView along with this.
There was a problem hiding this comment.
One other thought. Comparing the Block Settings Menus, I wonder if it's worth trying to standardize:
Button
Nav Link
Move Up / Move Down could be permanent additions to the normal menu when in contentOnly mode.
Add submenu link could be added through the slotfill that the normal menu exposes (though not completely sure if it works in contentOnly mode).
Delete is already present for both, but labelled differently.
Duplicate / Add before / Add after seem useful for nav links, so could be kept for both.
Maybe with that the custom blockSettingsMenu isn't needed
What?
Updates the ListView implementation in the Navigation block to use the same components as other blocks (List, Buttons, Social Icons) rather than having its own custom implementation.
Why?
It's generally better for us to have one implemention for features rather than duplicating, so the UX stays consistent and so we have less code to maintain.
How?
This PR refactors the list view system to be extensible, allowing any block to customize its list view presentation while using the same underlying infrastructure.
New listView block configuration:
Architecture:
- Reads blockType.listView configuration
- Renders custom components at specific extension points
- Removes hardcoded navigation special cases
- Wraps the list view header with navigation-specific state
- Uses the same hooks as the main edit component (useCreateNavigationMenu, useConvertClassicToBlockMenu)
- Provides menu selection, creation, and classic conversion callbacks
- Renders the menu selector dropdown in the list view panel header
- Consumes navigation context for current menu ID and callbacks
- Only shown when blockEditingMode === 'default'
- Provides inline link editing UI directly in the list view
- Handles entity binding for navigation links
- Auto-cleanup of empty navigation links
Testing Instructions
Basic Functionality
Pattern Context
Menu Selection
Creating Menus
Classic Menu Conversion (if classic menus are available)
Inline Link Editing
Block Editing Modes
Visual Regression
Screenshots or screencast
There should be no visual difference,