From 574f24a6791f550089bf2a9d5db19fa512b59467 Mon Sep 17 00:00:00 2001 From: Andrei Draganescu Date: Thu, 8 Dec 2022 19:03:04 +0000 Subject: [PATCH 01/13] adds page list as child of submenu and disables direct insert --- packages/block-library/src/navigation-submenu/edit.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/block-library/src/navigation-submenu/edit.js b/packages/block-library/src/navigation-submenu/edit.js index 47a222bd57bb6..86ce2ee3a9737 100644 --- a/packages/block-library/src/navigation-submenu/edit.js +++ b/packages/block-library/src/navigation-submenu/edit.js @@ -49,9 +49,9 @@ const ALLOWED_BLOCKS = [ 'core/page-list', ]; -const DEFAULT_BLOCK = { - name: 'core/navigation-link', -}; +// const DEFAULT_BLOCK = { +// name: 'core/navigation-link', +// }; /** * A React hook to determine if it's dragging within the target element. @@ -401,8 +401,8 @@ export default function NavigationSubmenuEdit( { }, { allowedBlocks, - __experimentalDefaultBlock: DEFAULT_BLOCK, - __experimentalDirectInsert: true, + // __experimentalDefaultBlock: DEFAULT_BLOCK, + // __experimentalDirectInsert: true, // Ensure block toolbar is not too far removed from item // being edited. From 06f3195df5c641b711847ddc7be47dd438bf4b2b Mon Sep 17 00:00:00 2001 From: Andrei Draganescu Date: Fri, 9 Dec 2022 12:41:18 +0000 Subject: [PATCH 02/13] fix page link CSS when adding to submenu, enable transform to pagelist, restore direct insert --- packages/block-library/src/navigation-submenu/edit.js | 10 +++++----- packages/block-library/src/page-list/style.scss | 10 ++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/block-library/src/navigation-submenu/edit.js b/packages/block-library/src/navigation-submenu/edit.js index 86ce2ee3a9737..47a222bd57bb6 100644 --- a/packages/block-library/src/navigation-submenu/edit.js +++ b/packages/block-library/src/navigation-submenu/edit.js @@ -49,9 +49,9 @@ const ALLOWED_BLOCKS = [ 'core/page-list', ]; -// const DEFAULT_BLOCK = { -// name: 'core/navigation-link', -// }; +const DEFAULT_BLOCK = { + name: 'core/navigation-link', +}; /** * A React hook to determine if it's dragging within the target element. @@ -401,8 +401,8 @@ export default function NavigationSubmenuEdit( { }, { allowedBlocks, - // __experimentalDefaultBlock: DEFAULT_BLOCK, - // __experimentalDirectInsert: true, + __experimentalDefaultBlock: DEFAULT_BLOCK, + __experimentalDirectInsert: true, // Ensure block toolbar is not too far removed from item // being edited. diff --git a/packages/block-library/src/page-list/style.scss b/packages/block-library/src/page-list/style.scss index d06a6142573be..8350e1d3380e8 100644 --- a/packages/block-library/src/page-list/style.scss +++ b/packages/block-library/src/page-list/style.scss @@ -15,3 +15,13 @@ background-color: inherit; } } + +.wp-block-navigation .wp-block-navigation__submenu-container { + .wp-block-page-list { + display: flex; + flex-direction: column; + justify-content: flex-start; + align-items: flex-start; + background-color: inherit; + } +} From 2274963193b0ffdb80ef40c7ac8896646f51a480 Mon Sep 17 00:00:00 2001 From: Andrei Draganescu Date: Mon, 12 Dec 2022 21:38:36 +0000 Subject: [PATCH 03/13] try to not render a wrapper if page list block is nested --- docs/reference-guides/core-blocks.md | 18 +++++++++--------- .../block-library/src/page-list/block.json | 4 ++++ packages/block-library/src/page-list/edit.js | 14 +++++++++++++- .../block-library/src/page-list/editor.scss | 10 ++++++++++ packages/block-library/src/page-list/index.php | 3 ++- 5 files changed, 38 insertions(+), 11 deletions(-) diff --git a/docs/reference-guides/core-blocks.md b/docs/reference-guides/core-blocks.md index 14f800f140aee..c45de8c5f8812 100644 --- a/docs/reference-guides/core-blocks.md +++ b/docs/reference-guides/core-blocks.md @@ -60,7 +60,7 @@ Prompt visitors to take action with a group of button-style links. ([Source](htt - **Name:** core/buttons - **Category:** design - **Supports:** align (full, wide), anchor, spacing (blockGap, margin), typography (fontSize, lineHeight) -- **Attributes:** +- **Attributes:** ## Calendar @@ -168,7 +168,7 @@ Contains the block elements used to display a comment, like the title, date, aut - **Name:** core/comment-template - **Category:** design - **Supports:** align, spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ -- **Attributes:** +- **Attributes:** ## Comments @@ -204,7 +204,7 @@ Displays a list of page numbers for comments pagination. ([Source](https://githu - **Name:** core/comments-pagination-numbers - **Category:** theme - **Supports:** color (background, gradients, ~~text~~), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ -- **Attributes:** +- **Attributes:** ## Comments Previous Page @@ -420,7 +420,7 @@ Separate your content into a multi-page experience. ([Source](https://github.com - **Name:** core/nextpage - **Category:** design - **Supports:** ~~className~~, ~~customClassName~~, ~~html~~ -- **Attributes:** +- **Attributes:** ## Page List @@ -429,7 +429,7 @@ Display a list of all pages. ([Source](https://github.com/WordPress/gutenberg/tr - **Name:** core/page-list - **Category:** widgets - **Supports:** typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ -- **Attributes:** parentPageID +- **Attributes:** isNested, parentPageID ## Page List Item @@ -528,7 +528,7 @@ Displays the contents of a post or page. ([Source](https://github.com/WordPress/ - **Name:** core/post-content - **Category:** theme - **Supports:** align (full, wide), dimensions (minHeight), typography (fontSize, lineHeight), ~~html~~ -- **Attributes:** +- **Attributes:** ## Post Date @@ -573,7 +573,7 @@ Contains the block elements used to render a post, like the title, date, feature - **Name:** core/post-template - **Category:** theme - **Supports:** align, color (background, gradients, link, text), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ -- **Attributes:** +- **Attributes:** ## Post Terms @@ -627,7 +627,7 @@ Contains the block elements used to render content when no query results are fou - **Name:** core/query-no-results - **Category:** theme - **Supports:** align, color (background, gradients, link, text), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ -- **Attributes:** +- **Attributes:** ## Pagination @@ -654,7 +654,7 @@ Displays a list of page numbers for pagination ([Source](https://github.com/Word - **Name:** core/query-pagination-numbers - **Category:** theme - **Supports:** color (background, gradients, ~~text~~), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ -- **Attributes:** +- **Attributes:** ## Previous Page diff --git a/packages/block-library/src/page-list/block.json b/packages/block-library/src/page-list/block.json index e8ff316a9fb4f..4f4f45c4bb474 100644 --- a/packages/block-library/src/page-list/block.json +++ b/packages/block-library/src/page-list/block.json @@ -11,6 +11,10 @@ "parentPageID": { "type": "integer", "default": 0 + }, + "isNested": { + "type": "boolean", + "default": false } }, "usesContext": [ diff --git a/packages/block-library/src/page-list/edit.js b/packages/block-library/src/page-list/edit.js index 7372191723f46..499687a7f5a7c 100644 --- a/packages/block-library/src/page-list/edit.js +++ b/packages/block-library/src/page-list/edit.js @@ -189,7 +189,7 @@ export default function PageListEdit( { const { replaceBlock, selectBlock } = useDispatch( blockEditorStore ); - const { parentNavBlockClientId } = useSelect( ( select ) => { + const { parentNavBlockClientId, isNested } = useSelect( ( select ) => { const { getSelectedBlockClientId, getBlockParentsByBlockName } = select( blockEditorStore ); @@ -201,9 +201,21 @@ export default function PageListEdit( { 'core/navigation', true )[ 0 ], + isNested: + getBlockParentsByBlockName( + _selectedBlockClientId, + 'core/navigation', + true + ).length > 0, }; }, [] ); + useEffect( () => { + if ( isNested ) { + setAttributes( { isNested } ); + } + }, [ isNested ] ); + return ( <> diff --git a/packages/block-library/src/page-list/editor.scss b/packages/block-library/src/page-list/editor.scss index 83a70bafd9485..4b759748adb49 100644 --- a/packages/block-library/src/page-list/editor.scss +++ b/packages/block-library/src/page-list/editor.scss @@ -22,6 +22,16 @@ } } +.wp-block-navigation .wp-block-navigation__submenu-container { + .wp-block-page-list { + display: flex; + flex-direction: column; + justify-content: flex-start; + align-items: flex-start; + background-color: inherit; + } +} + // Make links unclickable in the editor. .wp-block-pages-list__item__link { pointer-events: none; diff --git a/packages/block-library/src/page-list/index.php b/packages/block-library/src/page-list/index.php index 7944f6f3a84ad..03969d0ba78a6 100644 --- a/packages/block-library/src/page-list/index.php +++ b/packages/block-library/src/page-list/index.php @@ -253,6 +253,7 @@ function render_block_core_page_list( $attributes, $content, $block ) { ++$block_id; $parent_page_id = $attributes['parentPageID']; + $is_nested = $attributes['isNested']; $all_pages = get_pages( array( @@ -321,7 +322,7 @@ function render_block_core_page_list( $attributes, $content, $block ) { $show_submenu_icons = array_key_exists( 'showSubmenuIcon', $block->context ) ? $block->context['showSubmenuIcon'] : false; - $wrapper_markup = '
    %2$s
'; + $wrapper_markup = $is_nested ? '%2$s' : '
    %2$s
'; $items_markup = block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $nested_pages, $active_page_ancestor_ids, $colors ); From 1496c442fc1ba6fd83ea020a814dcbd0372d65bc Mon Sep 17 00:00:00 2001 From: Andrei Draganescu Date: Wed, 14 Dec 2022 11:36:28 +0000 Subject: [PATCH 04/13] Fixes styling, aligns off canvas implementation to list view, fixes styling bug of page list Co-authored-by: Dave Smith <444434+getdave@users.noreply.github.com> Co-authored-by: Maggie <3593343+MaggieCabrera@users.noreply.github.com> Co-authored-by: Ben Dwyer <275961+scruffian@users.noreply.github.com> --- .../block-library/src/page-list-item/edit.js | 89 ++++++++++++++++++- packages/block-library/src/page-list/edit.js | 37 ++++---- .../block-library/src/page-list/index.php | 8 +- 3 files changed, 110 insertions(+), 24 deletions(-) diff --git a/packages/block-library/src/page-list-item/edit.js b/packages/block-library/src/page-list-item/edit.js index db8e0a5c17373..9287502caee7e 100644 --- a/packages/block-library/src/page-list-item/edit.js +++ b/packages/block-library/src/page-list-item/edit.js @@ -6,7 +6,7 @@ import classnames from 'classnames'; /** * WordPress dependencies */ -import { InnerBlocks } from '@wordpress/block-editor'; +import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor'; import { useSelect } from '@wordpress/data'; import { store as coreStore } from '@wordpress/core-data'; @@ -30,10 +30,95 @@ function useFrontPageId() { }, [] ); } +/** + * Determine the colors for a menu. + * + * Order of priority is: + * 1: Overlay custom colors (if submenu) + * 2: Overlay theme colors (if submenu) + * 3: Custom colors + * 4: Theme colors + * 5: Global styles + * + * @param {Object} context + * @param {boolean} isSubMenu + */ +function getColors( context, isSubMenu ) { + const { + textColor, + customTextColor, + backgroundColor, + customBackgroundColor, + overlayTextColor, + customOverlayTextColor, + overlayBackgroundColor, + customOverlayBackgroundColor, + style, + } = context; + + const colors = {}; + + if ( isSubMenu && !! customOverlayTextColor ) { + colors.customTextColor = customOverlayTextColor; + } else if ( isSubMenu && !! overlayTextColor ) { + colors.textColor = overlayTextColor; + } else if ( !! customTextColor ) { + colors.customTextColor = customTextColor; + } else if ( !! textColor ) { + colors.textColor = textColor; + } else if ( !! style?.color?.text ) { + colors.customTextColor = style.color.text; + } + + if ( isSubMenu && !! customOverlayBackgroundColor ) { + colors.customBackgroundColor = customOverlayBackgroundColor; + } else if ( isSubMenu && !! overlayBackgroundColor ) { + colors.backgroundColor = overlayBackgroundColor; + } else if ( !! customBackgroundColor ) { + colors.customBackgroundColor = customBackgroundColor; + } else if ( !! backgroundColor ) { + colors.backgroundColor = backgroundColor; + } else if ( !! style?.color?.background ) { + colors.customTextColor = style.color.background; + } + + return colors; +} + export default function PageListItemEdit( { context, attributes } ) { const { id, label, link, hasChildren } = attributes; const isNavigationChild = 'showSubmenuIcon' in context; const frontPageId = useFrontPageId(); + + const innerBlocksColors = getColors( context, true ); + + const blockProps = useBlockProps( { + className: classnames( 'wp-block-page-list', { + 'has-text-color': !! ( + innerBlocksColors.textColor || innerBlocksColors.customTextColor + ), + [ `has-${ innerBlocksColors.textColor }-color` ]: + !! innerBlocksColors.textColor, + 'has-background': !! ( + innerBlocksColors.backgroundColor || + innerBlocksColors.customBackgroundColor + ), + [ `has-${ innerBlocksColors.backgroundColor }-background-color` ]: + !! innerBlocksColors.backgroundColor, + } ), + style: { + color: innerBlocksColors.customTextColor, + backgroundColor: innerBlocksColors.customBackgroundColor, + }, + } ); + + const innerBlocksProps = useInnerBlocksProps( blockProps, { + allowedBlocks: [ 'core/page-list-item' ], + renderAppender: false, + __unstableDisableDropZone: true, + templateLock: 'all', + } ); + return (
  • - +
  • ) } diff --git a/packages/block-library/src/page-list/edit.js b/packages/block-library/src/page-list/edit.js index 499687a7f5a7c..a28a943610dce 100644 --- a/packages/block-library/src/page-list/edit.js +++ b/packages/block-library/src/page-list/edit.js @@ -189,31 +189,32 @@ export default function PageListEdit( { const { replaceBlock, selectBlock } = useDispatch( blockEditorStore ); - const { parentNavBlockClientId, isNested } = useSelect( ( select ) => { - const { getSelectedBlockClientId, getBlockParentsByBlockName } = - select( blockEditorStore ); + const { parentNavBlockClientId, isNested } = useSelect( + ( select ) => { + const { getSelectedBlockClientId, getBlockParentsByBlockName } = + select( blockEditorStore ); - const _selectedBlockClientId = getSelectedBlockClientId(); + const _selectedBlockClientId = getSelectedBlockClientId(); - return { - parentNavBlockClientId: getBlockParentsByBlockName( - _selectedBlockClientId, - 'core/navigation', - true - )[ 0 ], - isNested: - getBlockParentsByBlockName( + return { + parentNavBlockClientId: getBlockParentsByBlockName( _selectedBlockClientId, 'core/navigation', true - ).length > 0, - }; - }, [] ); + )[ 0 ], + isNested: + getBlockParentsByBlockName( + clientId, + 'core/navigation-submenu', + true + ).length > 0, + }; + }, + [ clientId ] + ); useEffect( () => { - if ( isNested ) { - setAttributes( { isNested } ); - } + setAttributes( { isNested } ); }, [ isNested ] ); return ( diff --git a/packages/block-library/src/page-list/index.php b/packages/block-library/src/page-list/index.php index 03969d0ba78a6..fd3a97c964172 100644 --- a/packages/block-library/src/page-list/index.php +++ b/packages/block-library/src/page-list/index.php @@ -145,7 +145,7 @@ function block_core_page_list_build_css_font_sizes( $context ) { * * @return string List markup. */ -function block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $nested_pages, $active_page_ancestor_ids = array(), $colors = array(), $depth = 0 ) { +function block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $nested_pages, $active_page_ancestor_ids = array(), $colors = array(), $is_nested, $depth = 0 ) { if ( empty( $nested_pages ) ) { return; } @@ -173,7 +173,7 @@ function block_core_page_list_render_nested_page_list( $open_submenus_on_click, $navigation_child_content_class = $is_navigation_child ? ' wp-block-navigation-item__content' : ''; // If this is the first level of submenus, include the overlay colors. - if ( 1 === $depth && isset( $colors['overlay_css_classes'], $colors['overlay_inline_styles'] ) ) { + if ( ( ( 0 < $depth && ! $is_nested ) || $is_nested ) && isset( $colors['overlay_css_classes'], $colors['overlay_inline_styles'] ) ) { $css_class .= ' ' . trim( implode( ' ', $colors['overlay_css_classes'] ) ); if ( '' !== $colors['overlay_inline_styles'] ) { $style_attribute = sprintf( ' style="%s"', esc_attr( $colors['overlay_inline_styles'] ) ); @@ -212,7 +212,7 @@ function block_core_page_list_render_nested_page_list( $open_submenus_on_click, if ( $is_navigation_child ) { $markup .= ' wp-block-navigation__submenu-container'; } - $markup .= '">' . block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $page['children'], $active_page_ancestor_ids, $colors, $depth + 1 ) . ''; + $markup .= '">' . block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $page['children'], $active_page_ancestor_ids, $colors, $is_nested, $depth + 1 ) . ''; } $markup .= ''; } @@ -324,7 +324,7 @@ function render_block_core_page_list( $attributes, $content, $block ) { $wrapper_markup = $is_nested ? '%2$s' : '
      %2$s
    '; - $items_markup = block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $nested_pages, $active_page_ancestor_ids, $colors ); + $items_markup = block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $nested_pages, $active_page_ancestor_ids, $colors, $is_nested ); $wrapper_attributes = get_block_wrapper_attributes( array( From 60a7cc0bd5f30cf3222eb2b02248c65c2d7d62db Mon Sep 17 00:00:00 2001 From: Andrei Draganescu Date: Wed, 14 Dec 2022 12:07:02 +0000 Subject: [PATCH 05/13] fix fixture --- test/integration/fixtures/blocks/core__page-list.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/integration/fixtures/blocks/core__page-list.json b/test/integration/fixtures/blocks/core__page-list.json index b1992a437b884..2552d5e093c77 100644 --- a/test/integration/fixtures/blocks/core__page-list.json +++ b/test/integration/fixtures/blocks/core__page-list.json @@ -3,7 +3,8 @@ "name": "core/page-list", "isValid": true, "attributes": { - "parentPageID": 0 + "parentPageID": 0, + "isNested": false }, "innerBlocks": [] } From bb00b70c4c228b91cef2545f590f917dd35121c6 Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Thu, 15 Dec 2022 09:38:26 +0000 Subject: [PATCH 06/13] add missing useEffect --- packages/block-library/src/page-list/edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/page-list/edit.js b/packages/block-library/src/page-list/edit.js index a28a943610dce..219822ed87944 100644 --- a/packages/block-library/src/page-list/edit.js +++ b/packages/block-library/src/page-list/edit.js @@ -25,7 +25,7 @@ import { Button, } from '@wordpress/components'; import { __, sprintf } from '@wordpress/i18n'; -import { useMemo, useState } from '@wordpress/element'; +import { useMemo, useState, useEffect } from '@wordpress/element'; import { useEntityRecords } from '@wordpress/core-data'; import { useSelect, useDispatch } from '@wordpress/data'; From b1a21c56c346d3ad1eb78c95f027f8b4c7ceb2a6 Mon Sep 17 00:00:00 2001 From: Andrei Draganescu Date: Thu, 15 Dec 2022 15:58:50 +0000 Subject: [PATCH 07/13] Fixes markup rendering in the editor to avoid a double LI element Co-authored-by: Ben Dwyer <275961+scruffian@users.noreply.github.com> Co-authored-by: Maggie <3593343+MaggieCabrera@users.noreply.github.com> --- packages/block-library/src/page-list-item/edit.js | 14 ++++---------- packages/block-library/src/page-list/editor.scss | 10 ---------- packages/block-library/src/page-list/style.scss | 10 ---------- 3 files changed, 4 insertions(+), 30 deletions(-) diff --git a/packages/block-library/src/page-list-item/edit.js b/packages/block-library/src/page-list-item/edit.js index 9287502caee7e..206ef05adad66 100644 --- a/packages/block-library/src/page-list-item/edit.js +++ b/packages/block-library/src/page-list-item/edit.js @@ -93,7 +93,7 @@ export default function PageListItemEdit( { context, attributes } ) { const innerBlocksColors = getColors( context, true ); const blockProps = useBlockProps( { - className: classnames( 'wp-block-page-list', { + className: classnames( 'wp-block-pages-list__item', { 'has-text-color': !! ( innerBlocksColors.textColor || innerBlocksColors.customTextColor ), @@ -112,12 +112,7 @@ export default function PageListItemEdit( { context, attributes } ) { }, } ); - const innerBlocksProps = useInnerBlocksProps( blockProps, { - allowedBlocks: [ 'core/page-list-item' ], - renderAppender: false, - __unstableDisableDropZone: true, - templateLock: 'all', - } ); + const innerBlocksProps = useInnerBlocksProps( blockProps ); return (
  • -
  • - + { ...innerBlocksProps } + > ) } diff --git a/packages/block-library/src/page-list/editor.scss b/packages/block-library/src/page-list/editor.scss index 4b759748adb49..83a70bafd9485 100644 --- a/packages/block-library/src/page-list/editor.scss +++ b/packages/block-library/src/page-list/editor.scss @@ -22,16 +22,6 @@ } } -.wp-block-navigation .wp-block-navigation__submenu-container { - .wp-block-page-list { - display: flex; - flex-direction: column; - justify-content: flex-start; - align-items: flex-start; - background-color: inherit; - } -} - // Make links unclickable in the editor. .wp-block-pages-list__item__link { pointer-events: none; diff --git a/packages/block-library/src/page-list/style.scss b/packages/block-library/src/page-list/style.scss index 8350e1d3380e8..d06a6142573be 100644 --- a/packages/block-library/src/page-list/style.scss +++ b/packages/block-library/src/page-list/style.scss @@ -15,13 +15,3 @@ background-color: inherit; } } - -.wp-block-navigation .wp-block-navigation__submenu-container { - .wp-block-page-list { - display: flex; - flex-direction: column; - justify-content: flex-start; - align-items: flex-start; - background-color: inherit; - } -} From b58eb6a498ca5799de7d107f268eb39bab885b50 Mon Sep 17 00:00:00 2001 From: MaggieCabrera Date: Thu, 15 Dec 2022 17:41:19 +0100 Subject: [PATCH 08/13] added submenu container class to the page list item uls --- .../block-library/src/page-list-item/edit.js | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/packages/block-library/src/page-list-item/edit.js b/packages/block-library/src/page-list-item/edit.js index 206ef05adad66..aa0836e774848 100644 --- a/packages/block-library/src/page-list-item/edit.js +++ b/packages/block-library/src/page-list-item/edit.js @@ -93,19 +93,24 @@ export default function PageListItemEdit( { context, attributes } ) { const innerBlocksColors = getColors( context, true ); const blockProps = useBlockProps( { - className: classnames( 'wp-block-pages-list__item', { - 'has-text-color': !! ( - innerBlocksColors.textColor || innerBlocksColors.customTextColor - ), - [ `has-${ innerBlocksColors.textColor }-color` ]: - !! innerBlocksColors.textColor, - 'has-background': !! ( - innerBlocksColors.backgroundColor || - innerBlocksColors.customBackgroundColor - ), - [ `has-${ innerBlocksColors.backgroundColor }-background-color` ]: - !! innerBlocksColors.backgroundColor, - } ), + className: classnames( + 'wp-block-pages-list__item', + 'wp-block-navigation__submenu-container', + { + 'has-text-color': !! ( + innerBlocksColors.textColor || + innerBlocksColors.customTextColor + ), + [ `has-${ innerBlocksColors.textColor }-color` ]: + !! innerBlocksColors.textColor, + 'has-background': !! ( + innerBlocksColors.backgroundColor || + innerBlocksColors.customBackgroundColor + ), + [ `has-${ innerBlocksColors.backgroundColor }-background-color` ]: + !! innerBlocksColors.backgroundColor, + } + ), style: { color: innerBlocksColors.customTextColor, backgroundColor: innerBlocksColors.customBackgroundColor, From eab2170f4f94c281d32054bb401aabeb140a20bd Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Thu, 15 Dec 2022 17:14:45 +0000 Subject: [PATCH 09/13] Ensure submenus are correctly positioned in the editor --- packages/block-library/src/page-list/editor.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/block-library/src/page-list/editor.scss b/packages/block-library/src/page-list/editor.scss index 83a70bafd9485..4223b7adf63fa 100644 --- a/packages/block-library/src/page-list/editor.scss +++ b/packages/block-library/src/page-list/editor.scss @@ -22,6 +22,10 @@ } } +.wp-block-navigation .wp-block-navigation__submenu-container > .wp-block-page-list { + display: block; +} + // Make links unclickable in the editor. .wp-block-pages-list__item__link { pointer-events: none; From a071ca83e1acd684ebe5fb35d664e83adb068dce Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Thu, 15 Dec 2022 17:15:40 +0000 Subject: [PATCH 10/13] add a comment --- packages/block-library/src/page-list/editor.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/page-list/editor.scss b/packages/block-library/src/page-list/editor.scss index 4223b7adf63fa..4cda6018220d3 100644 --- a/packages/block-library/src/page-list/editor.scss +++ b/packages/block-library/src/page-list/editor.scss @@ -23,7 +23,7 @@ } .wp-block-navigation .wp-block-navigation__submenu-container > .wp-block-page-list { - display: block; + display: block; // This is needed to make sure the page list container is 100% wide, so that the children are correctly positioned. } // Make links unclickable in the editor. From cce7118704ad69ce108833c3b036573c7271c989 Mon Sep 17 00:00:00 2001 From: Andrei Draganescu Date: Fri, 16 Dec 2022 10:04:47 +0000 Subject: [PATCH 11/13] Docs formatting --- docs/reference-guides/core-blocks.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/reference-guides/core-blocks.md b/docs/reference-guides/core-blocks.md index c45de8c5f8812..25fe5746a0412 100644 --- a/docs/reference-guides/core-blocks.md +++ b/docs/reference-guides/core-blocks.md @@ -60,7 +60,7 @@ Prompt visitors to take action with a group of button-style links. ([Source](htt - **Name:** core/buttons - **Category:** design - **Supports:** align (full, wide), anchor, spacing (blockGap, margin), typography (fontSize, lineHeight) -- **Attributes:** +- **Attributes:** ## Calendar @@ -168,7 +168,7 @@ Contains the block elements used to display a comment, like the title, date, aut - **Name:** core/comment-template - **Category:** design - **Supports:** align, spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ -- **Attributes:** +- **Attributes:** ## Comments @@ -204,7 +204,7 @@ Displays a list of page numbers for comments pagination. ([Source](https://githu - **Name:** core/comments-pagination-numbers - **Category:** theme - **Supports:** color (background, gradients, ~~text~~), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ -- **Attributes:** +- **Attributes:** ## Comments Previous Page @@ -420,7 +420,7 @@ Separate your content into a multi-page experience. ([Source](https://github.com - **Name:** core/nextpage - **Category:** design - **Supports:** ~~className~~, ~~customClassName~~, ~~html~~ -- **Attributes:** +- **Attributes:** ## Page List @@ -528,7 +528,7 @@ Displays the contents of a post or page. ([Source](https://github.com/WordPress/ - **Name:** core/post-content - **Category:** theme - **Supports:** align (full, wide), dimensions (minHeight), typography (fontSize, lineHeight), ~~html~~ -- **Attributes:** +- **Attributes:** ## Post Date @@ -573,7 +573,7 @@ Contains the block elements used to render a post, like the title, date, feature - **Name:** core/post-template - **Category:** theme - **Supports:** align, color (background, gradients, link, text), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ -- **Attributes:** +- **Attributes:** ## Post Terms @@ -627,7 +627,7 @@ Contains the block elements used to render content when no query results are fou - **Name:** core/query-no-results - **Category:** theme - **Supports:** align, color (background, gradients, link, text), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ -- **Attributes:** +- **Attributes:** ## Pagination @@ -654,7 +654,7 @@ Displays a list of page numbers for pagination ([Source](https://github.com/Word - **Name:** core/query-pagination-numbers - **Category:** theme - **Supports:** color (background, gradients, ~~text~~), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ -- **Attributes:** +- **Attributes:** ## Previous Page From d7c60cba3e1af0e8d004963c88eedebfa82190a9 Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Fri, 16 Dec 2022 10:20:15 +0000 Subject: [PATCH 12/13] change the order of parameters --- packages/block-library/src/page-list/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/block-library/src/page-list/index.php b/packages/block-library/src/page-list/index.php index fd3a97c964172..b2d1affcd1850 100644 --- a/packages/block-library/src/page-list/index.php +++ b/packages/block-library/src/page-list/index.php @@ -145,7 +145,7 @@ function block_core_page_list_build_css_font_sizes( $context ) { * * @return string List markup. */ -function block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $nested_pages, $active_page_ancestor_ids = array(), $colors = array(), $is_nested, $depth = 0 ) { +function block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $nested_pages, $is_nested, $active_page_ancestor_ids = array(), $colors = array(), $depth = 0 ) { if ( empty( $nested_pages ) ) { return; } @@ -212,7 +212,7 @@ function block_core_page_list_render_nested_page_list( $open_submenus_on_click, if ( $is_navigation_child ) { $markup .= ' wp-block-navigation__submenu-container'; } - $markup .= '">' . block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $page['children'], $active_page_ancestor_ids, $colors, $is_nested, $depth + 1 ) . ''; + $markup .= '">' . block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $page['children'], $is_nested, $active_page_ancestor_ids, $colors, $depth + 1 ) . ''; } $markup .= ''; } @@ -324,7 +324,7 @@ function render_block_core_page_list( $attributes, $content, $block ) { $wrapper_markup = $is_nested ? '%2$s' : '
      %2$s
    '; - $items_markup = block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $nested_pages, $active_page_ancestor_ids, $colors, $is_nested ); + $items_markup = block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $nested_pages, $is_nested, $active_page_ancestor_ids, $colors ); $wrapper_attributes = get_block_wrapper_attributes( array( From f1d351a07548d39920091ffbbcec14acd4ec80e9 Mon Sep 17 00:00:00 2001 From: MaggieCabrera Date: Fri, 16 Dec 2022 12:33:42 +0100 Subject: [PATCH 13/13] linting and documentation --- packages/block-library/src/page-list/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/page-list/index.php b/packages/block-library/src/page-list/index.php index b2d1affcd1850..3ae63047e2748 100644 --- a/packages/block-library/src/page-list/index.php +++ b/packages/block-library/src/page-list/index.php @@ -139,6 +139,7 @@ function block_core_page_list_build_css_font_sizes( $context ) { * @param boolean $show_submenu_icons Whether to show submenu indicator icons. * @param boolean $is_navigation_child If block is a child of Navigation block. * @param array $nested_pages The array of nested pages. + * @param boolean $is_nested Whether the submenu is nested or not. * @param array $active_page_ancestor_ids An array of ancestor ids for active page. * @param array $colors Color information for overlay styles. * @param integer $depth The nesting depth. @@ -253,7 +254,7 @@ function render_block_core_page_list( $attributes, $content, $block ) { ++$block_id; $parent_page_id = $attributes['parentPageID']; - $is_nested = $attributes['isNested']; + $is_nested = $attributes['isNested']; $all_pages = get_pages( array(