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

Nav block content only representation #67389

Draft
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
30 changes: 24 additions & 6 deletions packages/block-editor/src/components/block-inspector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,15 @@ const BlockInspectorSingleBlock = ( {
const availableTabs = useInspectorControlsTabs( blockName );
const showTabs = ! isSectionBlock && availableTabs?.length > 1;

// HACK FOR TESTING PURPOSES.
const isNavigationBlock = useSelect(
Comment on lines +217 to +218
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do not ship with this in place.

( select ) => {
const { getBlockName } = select( blockEditorStore );
return getBlockName( clientId ) === 'core/navigation';
},
[ clientId ]
);

const hasBlockStyles = useSelect(
( select ) => {
const { getBlockStyles } = select( blocksStore );
Expand Down Expand Up @@ -266,12 +275,21 @@ const BlockInspectorSingleBlock = ( {
<BlockStylesPanel clientId={ clientId } />
) }

{ contentClientIds && contentClientIds?.length > 0 && (
<PanelBody title={ __( 'Content' ) }>
<BlockQuickNavigation
clientIds={ contentClientIds }
/>
</PanelBody>
{ ! isNavigationBlock &&
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could make this condition some kind of private editor setting. We can then pass in the various blocks we want to enable this behaviour for.

contentClientIds &&
contentClientIds?.length > 0 && (
<PanelBody title={ __( 'Content' ) }>
<BlockQuickNavigation
clientIds={ contentClientIds }
/>
</PanelBody>
) }

{ isNavigationBlock && (
<>
<InspectorControls.Slot />
<InspectorControls.Slot group="list" />
</>
) }

{ ! isSectionBlock && (
Expand Down
12 changes: 8 additions & 4 deletions packages/block-library/src/navigation-link/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
"textdomain": "default",
"attributes": {
"label": {
"type": "string"
"type": "string",
"role": "content"
},
"type": {
"type": "string"
},
"description": {
"type": "string"
"type": "string",
"role": "content"
},
"rel": {
"type": "string"
Expand All @@ -33,10 +35,12 @@
"default": false
},
"url": {
"type": "string"
"type": "string",
"role": "content"
},
"title": {
"type": "string"
"type": "string",
"role": "content"
},
"kind": {
"type": "string"
Expand Down
12 changes: 8 additions & 4 deletions packages/block-library/src/navigation-submenu/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
"textdomain": "default",
"attributes": {
"label": {
"type": "string"
"type": "string",
"role": "content"
},
"type": {
"type": "string"
},
"description": {
"type": "string"
"type": "string",
"role": "content"
},
"rel": {
"type": "string"
Expand All @@ -28,10 +30,12 @@
"default": false
},
"url": {
"type": "string"
"type": "string",
"role": "content"
},
"title": {
"type": "string"
"type": "string",
"role": "content"
},
"kind": {
"type": "string"
Expand Down
3 changes: 2 additions & 1 deletion packages/block-library/src/page-list/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
},
"isNested": {
"type": "boolean",
"default": false
"default": false,
"role": "content"
}
},
"usesContext": [
Expand Down
Loading