Skip to content

Commit

Permalink
Limit back to Nav block and always skip to Nav block (#46037)
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave authored Nov 25, 2022
1 parent d40cc5c commit 362a6c4
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/block-editor/src/components/block-card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ function BlockCard( { title, icon, description, blockType, className } ) {
const isOffCanvasNavigationEditorEnabled =
window?.__experimentalEnableOffCanvasNavigationEditor === true;

const { parentBlockClientId } = useSelect( ( select ) => {
const { getSelectedBlockClientId, getBlockParents } =
const { parentNavBlockClientId } = useSelect( ( select ) => {
const { getSelectedBlockClientId, getBlockParentsByBlockName } =
select( blockEditorStore );

const _selectedBlockClientId = getSelectedBlockClientId();

return {
parentBlockClientId: getBlockParents(
parentNavBlockClientId: getBlockParentsByBlockName(
_selectedBlockClientId,
'core/navigation',
true
)[ 0 ],
};
Expand All @@ -48,10 +49,10 @@ function BlockCard( { title, icon, description, blockType, className } ) {

return (
<div className={ classnames( 'block-editor-block-card', className ) }>
{ isOffCanvasNavigationEditorEnabled && parentBlockClientId && (
{ isOffCanvasNavigationEditorEnabled && parentNavBlockClientId && (
<Button
onClick={ () => selectBlock( parentBlockClientId ) }
label={ __( 'Navigate to parent block' ) }
onClick={ () => selectBlock( parentNavBlockClientId ) }
label={ __( 'Go to parent Navigation block' ) }
style={
// TODO: This style override is also used in ToolsPanelHeader.
// It should be supported out-of-the-box by Button.
Expand Down

0 comments on commit 362a6c4

Please sign in to comment.