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

Fix navigation block inserter behavior: prioritize submenus and disable direct insert. #68263

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions packages/block-library/src/navigation/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const DEFAULT_BLOCK = {
export const PRIORITIZED_INSERTER_BLOCKS = [
'core/navigation-link/page',
'core/navigation-link',
'core/navigation-submenu',
];

// These parameters must be kept aligned with those in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default function NavigationInnerBlocks( {
onChange,
prioritizedInserterBlocks: PRIORITIZED_INSERTER_BLOCKS,
defaultBlock: DEFAULT_BLOCK,
directInsert: true,
directInsert: false,
orientation,
templateLock,

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { useInnerBlocksProps } from '@wordpress/block-editor';
import { useInnerBlocksProps, InnerBlocks } from '@wordpress/block-editor';
import { Disabled } from '@wordpress/components';
import { store as coreStore } from '@wordpress/core-data';
import { useSelect } from '@wordpress/data';
Expand All @@ -11,7 +11,11 @@ import { useContext, useEffect, useRef } from '@wordpress/element';
* Internal dependencies
*/
import { areBlocksDirty } from './are-blocks-dirty';
import { DEFAULT_BLOCK, SELECT_NAVIGATION_MENUS_ARGS } from '../constants';
import {
DEFAULT_BLOCK,
SELECT_NAVIGATION_MENUS_ARGS,
PRIORITIZED_INSERTER_BLOCKS,
} from '../constants';

const EMPTY_OBJECT = {};

Expand Down Expand Up @@ -51,9 +55,12 @@ export default function UnsavedInnerBlocks( {
className: 'wp-block-navigation__container',
},
{
renderAppender: hasSelection ? undefined : false,
renderAppender: hasSelection
? InnerBlocks.ButtonBlockAppender
: false,
defaultBlock: DEFAULT_BLOCK,
directInsert: true,
directInsert: false,
prioritizedInserterBlocks: PRIORITIZED_INSERTER_BLOCKS,
}
);

Expand Down
Loading