Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Make block inspector accept default tab from block type
  • Loading branch information
aaronrobertshaw committed Oct 26, 2022
commit 0dd9e460d0febecc078ce8af1e419fbe3ef45b36
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { hasBlockSupport } from '@wordpress/blocks';
import { getBlockType, hasBlockSupport } from '@wordpress/blocks';
import {
PanelBody,
TabPanel,
Expand Down Expand Up @@ -115,11 +115,15 @@ export default function InspectorControlsTabs( {
}
}

const blockType = getBlockType( blockName );

// We have multiple tabs with contents so render complete TabPanel.
return (
<TabPanel
className="block-editor-block-inspector__tabs"
tabs={ availableTabs }
initialTabName={ blockType.defaultTab }
key={ clientId }
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open to better approaches here to force the tab panel to reflect different block types' default tabs.

>
{ ( tab ) => {
if ( tab.name === TAB_MENU.name ) {
Expand Down