-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Enable navigation nesting to be filtered and manually set #38621
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
Changes from all commits
70b6e7f
4ad4fdb
2727aaf
9541e7f
c1c4b1a
51a2a9a
debc62e
2432333
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,7 @@ | |
| "fontSize", | ||
| "customFontSize", | ||
| "showSubmenuIcon", | ||
| "maxNestingLevel", | ||
| "style" | ||
| ], | ||
| "supports": { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
| * External dependencies | ||
| */ | ||
| import classnames from 'classnames'; | ||
| import { escape, pull } from 'lodash'; | ||
| import { escape, without } from 'lodash'; | ||
|
|
||
| /** | ||
| * WordPress dependencies | ||
|
|
@@ -55,8 +55,6 @@ const DEFAULT_BLOCK = { | |
| name: 'core/navigation-link', | ||
| }; | ||
|
|
||
| const MAX_NESTING = 5; | ||
|
|
||
| /** | ||
| * A React hook to determine if it's dragging within the target element. | ||
| * | ||
|
|
@@ -293,7 +291,7 @@ export default function NavigationSubmenuEdit( { | |
| url, | ||
| opensInNewTab, | ||
| }; | ||
| const { showSubmenuIcon, openSubmenusOnClick } = context; | ||
| const { showSubmenuIcon, maxNestingLevel, openSubmenusOnClick } = context; | ||
| const { saveEntityRecord } = useDispatch( coreStore ); | ||
|
|
||
| const { | ||
|
|
@@ -351,7 +349,7 @@ export default function NavigationSubmenuEdit( { | |
| return { | ||
| isAtMaxNesting: | ||
| getBlockParentsByBlockName( clientId, name ).length >= | ||
| MAX_NESTING, | ||
| maxNestingLevel, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add this to the dependency array for the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure ... This does not change dynamically ... I see a future where this will have an inspector control for when building themes, but until then it's a value from the markup. |
||
| isTopLevelItem: | ||
| getBlockParentsByBlockName( clientId, name ).length === 0, | ||
| isParentOfSelectedBlock: hasSelectedInnerBlock( | ||
|
|
@@ -503,9 +501,9 @@ export default function NavigationSubmenuEdit( { | |
| // Always use overlay colors for submenus. | ||
| const innerBlocksColors = getColors( context, true ); | ||
|
|
||
| if ( isAtMaxNesting ) { | ||
| pull( ALLOWED_BLOCKS, 'core/navigation-submenu' ); | ||
| } | ||
| const allowedBlocks = isAtMaxNesting | ||
| ? without( ALLOWED_BLOCKS, 'core/navigation-submenu' ) | ||
| : ALLOWED_BLOCKS; | ||
|
|
||
| const innerBlocksProps = useInnerBlocksProps( | ||
| { | ||
|
|
@@ -528,7 +526,7 @@ export default function NavigationSubmenuEdit( { | |
| }, | ||
| }, | ||
| { | ||
| allowedBlocks: ALLOWED_BLOCKS, | ||
| allowedBlocks, | ||
| __experimentalDefaultBlock: DEFAULT_BLOCK, | ||
| __experimentalDirectInsert: true, | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest calling this
maxLevel