From 35b73672614e496a1d4523e1be9756ab8ce82768 Mon Sep 17 00:00:00 2001 From: Kai Hao Date: Mon, 12 Oct 2020 13:01:53 +0800 Subject: [PATCH] Only hide when parent is widget-area --- lib/widgets-page.php | 8 ++++---- .../src/components/block-parent-selector/index.js | 4 ++++ .../block-editor/src/components/block-toolbar/index.js | 4 +--- packages/edit-widgets/src/blocks/widget-area/index.js | 1 + 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/widgets-page.php b/lib/widgets-page.php index f611908f2a5605..c7a2b0e132ba3d 100644 --- a/lib/widgets-page.php +++ b/lib/widgets-page.php @@ -70,10 +70,9 @@ function gutenberg_widgets_init( $hook ) { $settings = array_merge( array( - 'imageSizes' => $available_image_sizes, - 'isRTL' => is_rtl(), - 'maxUploadFileSize' => $max_upload_size, - 'hideParentSelector' => true, + 'imageSizes' => $available_image_sizes, + 'isRTL' => is_rtl(), + 'maxUploadFileSize' => $max_upload_size, ), gutenberg_get_legacy_widget_settings() ); @@ -142,3 +141,4 @@ function gutenberg_widgets_editor_load_block_editor_scripts_and_styles( $is_bloc } add_filter( 'should_load_block_editor_scripts_and_styles', 'gutenberg_widgets_editor_load_block_editor_scripts_and_styles' ); + diff --git a/packages/block-editor/src/components/block-parent-selector/index.js b/packages/block-editor/src/components/block-parent-selector/index.js index c6b7a458ea3887..e47295e4498998 100644 --- a/packages/block-editor/src/components/block-parent-selector/index.js +++ b/packages/block-editor/src/components/block-parent-selector/index.js @@ -35,6 +35,10 @@ export default function BlockParentSelector() { }; }, [] ); + if ( parentBlockType.hideParentSelector ) { + return null; + } + if ( firstParentClientId !== undefined ) { return (
{ @@ -59,7 +58,6 @@ export default function BlockToolbar( { getBlockType( getBlockName( selectedBlockClientId ) ), hasFixedToolbar: settings.hasFixedToolbar, hasReducedUI: settings.hasReducedUI, - hideParentSelector: !! settings.hideParentSelector, rootClientId: blockRootClientId, isValid: selectedBlockClientIds.every( ( id ) => isBlockValid( id ) @@ -115,7 +113,7 @@ export default function BlockToolbar( { return (
- { ! hideParentSelector && ! isMultiToolbar && ( + { ! isMultiToolbar && (
diff --git a/packages/edit-widgets/src/blocks/widget-area/index.js b/packages/edit-widgets/src/blocks/widget-area/index.js index 326705421ee0a3..3902b793809307 100644 --- a/packages/edit-widgets/src/blocks/widget-area/index.js +++ b/packages/edit-widgets/src/blocks/widget-area/index.js @@ -16,5 +16,6 @@ export const settings = { title: __( 'Widget Area' ), description: __( 'A widget area container.' ), __experimentalLabel: ( { name: label } ) => label, + hideParentSelector: true, edit, };