From 306063698fa9a033b4a006851414e60425c15a3d Mon Sep 17 00:00:00 2001 From: scruffian Date: Wed, 3 May 2023 12:22:28 +0100 Subject: [PATCH] Replace OffCanvasEditor in browse mode with the List View component Add context to the block icon in list view update comment add another prop to list view change fixed color renamed blockSettingsMenu prop --- .../components/list-view/block-select-button.js | 6 +++++- .../src/components/list-view/index.js | 15 +++++++++++---- .../navigation-menu-content.js | 6 +++--- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/block-editor/src/components/list-view/block-select-button.js b/packages/block-editor/src/components/list-view/block-select-button.js index 21759d205845a..068688a7d5603 100644 --- a/packages/block-editor/src/components/list-view/block-select-button.js +++ b/packages/block-editor/src/components/list-view/block-select-button.js @@ -84,7 +84,11 @@ function ListViewBlockSelectButton( aria-expanded={ isExpanded } > - + { const { @@ -130,11 +133,14 @@ function ListViewComponent( setExpandedState, } ); const selectEditorBlock = useCallback( - ( event, clientId ) => { - updateBlockSelection( event, clientId ); - setSelectedTreeId( clientId ); + ( event, blockClientId ) => { + updateBlockSelection( event, blockClientId ); + setSelectedTreeId( blockClientId ); + if ( onSelect ) { + onSelect( getBlock( blockClientId ) ); + } }, - [ setSelectedTreeId, updateBlockSelection ] + [ setSelectedTreeId, updateBlockSelection, onSelect, getBlock ] ); useEffect( () => { isMounted.current = true; @@ -268,6 +274,7 @@ export default forwardRef( ( props, ref ) => { showAppender={ false } blockSettingsMenu={ BlockSettingsDropdown } rootClientId={ null } + onSelect={ null } renderAdditionalBlockUICallback={ null } /> ); diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js b/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js index 2981c57c19fd1..d7d4e18fc2b51 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js @@ -144,7 +144,7 @@ export default function NavigationMenuContent( { rootClientId, onSelect } ) { }; }, [ shouldKeepLoading, clientIdsTree, isLoading ] ); - const { OffCanvasEditor, LeafMoreMenu } = unlock( blockEditorPrivateApis ); + const { PrivateListView, LeafMoreMenu } = unlock( blockEditorPrivateApis ); const offCanvasOnselect = useCallback( ( block ) => { @@ -181,14 +181,14 @@ export default function NavigationMenuContent( { rootClientId, onSelect } ) { <> { isLoading && } { ! isLoading && ( -