Skip to content
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

Sidebar Tabs: Stabilize the block inspector tabs experiment #47045

Merged
merged 14 commits into from
Jan 11, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,6 @@ public function get_item_schema() {
'context' => array( 'mobile' ),
),

'__experimentalBlockInspectorTabs' => array(
'description' => __( 'Block inspector tab display overrides.', 'gutenberg' ),
'type' => 'object',
'context' => array( 'post-editor', 'site-editor', 'widgets-editor' ),
),

'__experimentalBlockInspectorAnimation' => array(
'description' => __( 'Whether to enable animation when showing and hiding the block inspector.', 'gutenberg' ),
'type' => 'object',
Expand Down Expand Up @@ -204,6 +198,12 @@ public function get_item_schema() {
'context' => array( 'post-editor', 'site-editor', 'widgets-editor' ),
),

'blockInspectorTabs' => array(
'description' => __( 'Block inspector tab display overrides.', 'gutenberg' ),
'type' => 'object',
'context' => array( 'post-editor', 'site-editor', 'widgets-editor' ),
),

'disableCustomColors' => array(
'description' => __( 'Disables custom colors.', 'gutenberg' ),
'type' => 'boolean',
Expand Down
3 changes: 0 additions & 3 deletions lib/experimental/editor-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ function gutenberg_enable_experiments() {
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-off-canvas-navigation-editor', $gutenberg_experiments ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalEnableOffCanvasNavigationEditor = true', 'before' );
}
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-block-inspector-tabs', $gutenberg_experiments ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalEnableBlockInspectorTabs = true', 'before' );
}
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-global-styles-custom-css', $gutenberg_experiments ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalEnableGlobalStylesCustomCSS = true', 'before' );
}
Expand Down
12 changes: 0 additions & 12 deletions lib/experiments-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,6 @@ function gutenberg_initialize_experiments_settings() {
)
);

add_settings_field(
'gutenberg-block-inspector-tabs',
__( 'Block inspector tabs ', 'gutenberg' ),
'gutenberg_display_experiment_field',
'gutenberg-experiments',
'gutenberg_experiments_section',
array(
'label' => __( 'Test a new block inspector view splitting settings and appearance controls into tabs', 'gutenberg' ),
'id' => 'gutenberg-block-inspector-tabs',
)
);

add_settings_field(
'gutenberg-global-styles-custom-css',
__( 'Global styles custom css ', 'gutenberg' ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ import { store as blockEditorStore } from '../../store';
const EMPTY_ARRAY = [];

function getShowTabs( blockName, tabSettings = {} ) {
// Don't allow settings to force the display of tabs if the block inspector
// tabs experiment hasn't been opted into.
if ( ! window?.__experimentalEnableBlockInspectorTabs ) {
return false;
}

// Block specific setting takes precedence over generic default.
if ( tabSettings[ blockName ] !== undefined ) {
return tabSettings[ blockName ];
Expand All @@ -42,16 +36,14 @@ export default function useInspectorControlsTabs( blockName ) {
color: colorGroup,
default: defaultGroup,
dimensions: dimensionsGroup,
list: listGroup,
position: positionGroup,
typography: typographyGroup,
} = InspectorControlsGroups;

// List View Tab: If there are any fills for the list group add that tab.
const listViewDisabled = useIsListViewTabDisabled( blockName );
const listFills = useSlotFills( listGroup.Slot.__unstableName );

if ( ! listViewDisabled && !! listFills && listFills.length ) {
if ( ! listViewDisabled ) {
aaronrobertshaw marked this conversation as resolved.
Show resolved Hide resolved
tabs.push( TAB_LIST_VIEW );
}

Expand Down Expand Up @@ -81,8 +73,7 @@ export default function useInspectorControlsTabs( blockName ) {
}

const tabSettings = useSelect( ( select ) => {
return select( blockEditorStore ).getSettings()
.__experimentalBlockInspectorTabs;
return select( blockEditorStore ).getSettings().blockInspectorTabs;
}, [] );

const showTabs = getShowTabs( blockName, tabSettings );
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/navigation-link/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,11 @@ function register_block_core_navigation_link() {
function gutenberg_disable_tabs_for_navigation_link_block( $settings ) {
$current_tab_settings = _wp_array_get(
$settings,
array( '__experimentalBlockInspectorTabs' ),
array( 'blockInspectorTabs' ),
array()
);

$settings['__experimentalBlockInspectorTabs'] = array_merge(
$settings['blockInspectorTabs'] = array_merge(
$current_tab_settings,
array( 'core/navigation-link' => false )
);
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/navigation-submenu/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,11 @@ function register_block_core_navigation_submenu() {
function gutenberg_disable_tabs_for_navigation_submenu_block( $settings ) {
$current_tab_settings = _wp_array_get(
$settings,
array( '__experimentalBlockInspectorTabs' ),
array( 'blockInspectorTabs' ),
array()
);

$settings['__experimentalBlockInspectorTabs'] = array_merge(
$settings['blockInspectorTabs'] = array_merge(
$current_tab_settings,
array( 'core/navigation-submenu' => false )
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,9 @@ const DefaultControls = ( props ) => {
const MenuInspectorControls = ( props ) => {
const isOffCanvasNavigationEditorEnabled =
window?.__experimentalEnableOffCanvasNavigationEditor === true;
const menuControlsSlot = window?.__experimentalEnableBlockInspectorTabs
? 'list'
: undefined;

return (
<InspectorControls __experimentalGroup={ menuControlsSlot }>
<InspectorControls __experimentalGroup="list">
aaronrobertshaw marked this conversation as resolved.
Show resolved Hide resolved
<PanelBody
title={
isOffCanvasNavigationEditorEnabled ? null : __( 'Menu' )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ function useBlockEditorSettings( settings, hasTemplate ) {
Object.entries( settings ).filter( ( [ key ] ) =>
[
'__experimentalBlockDirectory',
'__experimentalBlockInspectorTabs',
'__experimentalDiscussionSettings',
'__experimentalFeatures',
'__experimentalPreferredStyleVariations',
'__experimentalSetIsInserterOpened',
'__unstableGalleryWithImageBlocks',
'alignWide',
'allowedBlockTypes',
'blockInspectorTabs',
'bodyPlaceholder',
'canLockBlocks',
'codeEditingEnabled',
Expand Down