From c4dac5e1c2b17e97acc92740619b65ce6148e7b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Ventura?= Date: Sun, 10 Nov 2019 18:14:14 +0100 Subject: [PATCH 01/11] Rename "Navigation Menu Item" to "Link". --- .../src/navigation-menu-item/block.json | 2 +- .../src/navigation-menu-item/edit.js | 36 +++++++++---------- .../src/navigation-menu-item/index.js | 6 ++-- .../block-library/src/navigation-menu/edit.js | 4 +-- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/packages/block-library/src/navigation-menu-item/block.json b/packages/block-library/src/navigation-menu-item/block.json index 2954aa92683195..3d6d79f73bde2c 100644 --- a/packages/block-library/src/navigation-menu-item/block.json +++ b/packages/block-library/src/navigation-menu-item/block.json @@ -1,5 +1,5 @@ { - "name": "core/navigation-menu-item", + "name": "core/navigation-link", "category": "layout", "attributes": { "label": { diff --git a/packages/block-library/src/navigation-menu-item/edit.js b/packages/block-library/src/navigation-menu-item/edit.js index 09e62499f84c15..4731c0e1e281ec 100644 --- a/packages/block-library/src/navigation-menu-item/edit.js +++ b/packages/block-library/src/navigation-menu-item/edit.js @@ -56,7 +56,7 @@ const updateLinkSetting = ( setter ) => ( setting, value ) => { * through of the `onLinkChange` LinkControl callback. * * @param {Function} setter Setter attribute function. - * @param {string} label ItemMenu link label. + * @param {string} label Link label. */ const updateLink = ( setter, label ) => ( { title: newTitle = '', url: newURL = '' } = {} ) => { setter( { @@ -70,13 +70,13 @@ const updateLink = ( setter, label ) => ( { title: newTitle = '', url: newURL = } }; -function NavigationMenuItemEdit( { +function NavigationLinkEdit( { attributes, hasDescendants, isSelected, isParentOfSelectedBlock, setAttributes, - insertMenuItemBlock, + insertLinkBlock, } ) { const { label, opensInNewTab, title, url } = attributes; const link = title ? { title, url } : null; @@ -116,7 +116,7 @@ function NavigationMenuItemEdit( { * `onKeyDown` LinkControl handler. * It takes over to stop the event propagation to make the * navigation work, avoiding undesired behaviors. - * For instance, it will block to move between menu items + * For instance, it will block to move between link blocks * when the LinkControl is focused. * * @param {Event} event @@ -130,7 +130,7 @@ function NavigationMenuItemEdit( { } }; - const itemLabelPlaceholder = __( 'Add item…' ); + const itemLabelPlaceholder = __( 'Add link…' ); return ( @@ -152,14 +152,14 @@ function NavigationMenuItemEdit( { } - title={ __( 'Add submenu item' ) } - onClick={ insertMenuItemBlock } + title={ __( 'Add Submenu' ) } + onClick={ insertLinkBlock } /> { setAttributes( { nofollow } ); } } - label={ __( 'Add nofollow to menu item' ) } + label={ __( 'Add nofollow to link' ) } help={ ( { __( 'Don\'t let search engines follow this link.' ) } { __( 'What\'s this?' ) } @@ -208,15 +208,15 @@ function NavigationMenuItemEdit( {
-
+
setAttributes( { label: labelValue } ) } placeholder={ itemLabelPlaceholder } @@ -224,7 +224,7 @@ function NavigationMenuItemEdit( { /> { isLinkOpen && ( event.stopPropagation() } currentLink={ link } @@ -244,7 +244,7 @@ function NavigationMenuItemEdit( { ) }
@@ -264,7 +264,7 @@ export default compose( [ } ), withDispatch( ( dispatch, ownProps, registry ) => { return { - insertMenuItemBlock() { + insertLinkBlock() { const { clientId } = ownProps; const { @@ -275,7 +275,7 @@ export default compose( [ const navItems = getClientIdsOfDescendants( [ clientId ] ); const insertionPoint = navItems.length ? navItems.length : 0; - const blockToInsert = createBlock( 'core/navigation-menu-item' ); + const blockToInsert = createBlock( 'core/navigation-link' ); insertBlock( blockToInsert, @@ -285,4 +285,4 @@ export default compose( [ }, }; } ), -] )( NavigationMenuItemEdit ); +] )( NavigationLinkEdit ); diff --git a/packages/block-library/src/navigation-menu-item/index.js b/packages/block-library/src/navigation-menu-item/index.js index 368af23b189c59..30c5ecc26849c3 100644 --- a/packages/block-library/src/navigation-menu-item/index.js +++ b/packages/block-library/src/navigation-menu-item/index.js @@ -14,13 +14,13 @@ const { name } = metadata; export { metadata, name }; export const settings = { - title: __( 'Menu Item' ), + title: __( 'Navigation Link' ), - parent: [ 'core/navigation-menu' ], + parent: [ 'core/navigation-link' ], icon: , - description: __( 'Add a page, link, or other item to your Navigation Menu.' ), + description: __( 'Add a page, link, or other item to your navigation.' ), __experimentalDisplayName: 'label', diff --git a/packages/block-library/src/navigation-menu/edit.js b/packages/block-library/src/navigation-menu/edit.js index d29efe29150d19..15b71ebfc0d6f5 100644 --- a/packages/block-library/src/navigation-menu/edit.js +++ b/packages/block-library/src/navigation-menu/edit.js @@ -71,7 +71,7 @@ function NavigationMenu( { } return pages.map( ( { title, type, link: url, id } ) => ( - createBlock( 'core/navigation-menu-item', + createBlock( 'core/navigation-link', { type, id, @@ -210,7 +210,7 @@ function NavigationMenu( { { ! hasExistingNavItems && isRequestingPages && <> { __( 'Loading Navigation…' ) } } From 9726170ea518257bdc0cd092bb03aa02af7102df Mon Sep 17 00:00:00 2001 From: Konstantin Obenland Date: Wed, 13 Nov 2019 16:50:19 -0800 Subject: [PATCH 02/11] Updating a few more menu item mentions If we end up going with a different term, at least we'll have a better idea what it all is that needs updating. --- packages/block-library/src/editor.scss | 2 +- packages/block-library/src/index.js | 4 ++-- .../block.json | 0 .../edit.js | 0 .../editor.scss | 24 +++++++++---------- .../index.js | 2 +- .../save.js | 0 .../block-library/src/navigation-menu/edit.js | 2 +- .../src/navigation-menu/index.php | 20 ++++++++-------- .../blocks/core__navigation-link.html | 2 ++ ...u-item.json => core__navigation-link.json} | 2 +- ...json => core__navigation-link.parsed.json} | 2 +- .../core__navigation-link.serialized.html | 1 + .../blocks/core__navigation-menu-item.html | 2 -- ...core__navigation-menu-item.serialized.html | 1 - 15 files changed, 32 insertions(+), 32 deletions(-) rename packages/block-library/src/{navigation-menu-item => navigation-link}/block.json (100%) rename packages/block-library/src/{navigation-menu-item => navigation-link}/edit.js (100%) rename packages/block-library/src/{navigation-menu-item => navigation-link}/editor.scss (76%) rename packages/block-library/src/{navigation-menu-item => navigation-link}/index.js (94%) rename packages/block-library/src/{navigation-menu-item => navigation-link}/save.js (100%) create mode 100644 packages/e2e-tests/fixtures/blocks/core__navigation-link.html rename packages/e2e-tests/fixtures/blocks/{core__navigation-menu-item.json => core__navigation-link.json} (87%) rename packages/e2e-tests/fixtures/blocks/{core__navigation-menu-item.parsed.json => core__navigation-link.parsed.json} (88%) create mode 100644 packages/e2e-tests/fixtures/blocks/core__navigation-link.serialized.html delete mode 100644 packages/e2e-tests/fixtures/blocks/core__navigation-menu-item.html delete mode 100644 packages/e2e-tests/fixtures/blocks/core__navigation-menu-item.serialized.html diff --git a/packages/block-library/src/editor.scss b/packages/block-library/src/editor.scss index 59569f4105ba2c..579798ff812faf 100644 --- a/packages/block-library/src/editor.scss +++ b/packages/block-library/src/editor.scss @@ -18,8 +18,8 @@ @import "./legacy-widget/editor.scss"; @import "./media-text/editor.scss"; @import "./more/editor.scss"; +@import "./navigation-link/editor.scss"; @import "./navigation-menu/editor.scss"; -@import "./navigation-menu-item/editor.scss"; @import "./nextpage/editor.scss"; @import "./paragraph/editor.scss"; @import "./pullquote/editor.scss"; diff --git a/packages/block-library/src/index.js b/packages/block-library/src/index.js index 3147ebcc0e9cdc..e5e18daa200c60 100644 --- a/packages/block-library/src/index.js +++ b/packages/block-library/src/index.js @@ -34,8 +34,8 @@ import * as embed from './embed'; import * as file from './file'; import * as html from './html'; import * as mediaText from './media-text'; +import * as navigationLink from './navigation-link'; import * as navigationMenu from './navigation-menu'; -import * as navigationMenuItem from './navigation-menu-item'; import * as latestComments from './latest-comments'; import * as latestPosts from './latest-posts'; import * as legacyWidget from './legacy-widget'; @@ -177,7 +177,7 @@ export const __experimentalRegisterExperimentalCoreBlocks = ;[ __experimentalEnableLegacyWidgetBlock ? legacyWidget : null, __experimentalEnableMenuBlock ? navigationMenu : null, - __experimentalEnableMenuBlock ? navigationMenuItem : null, + __experimentalEnableMenuBlock ? navigationLink : null, socialLinks, ...socialLink.sites, diff --git a/packages/block-library/src/navigation-menu-item/block.json b/packages/block-library/src/navigation-link/block.json similarity index 100% rename from packages/block-library/src/navigation-menu-item/block.json rename to packages/block-library/src/navigation-link/block.json diff --git a/packages/block-library/src/navigation-menu-item/edit.js b/packages/block-library/src/navigation-link/edit.js similarity index 100% rename from packages/block-library/src/navigation-menu-item/edit.js rename to packages/block-library/src/navigation-link/edit.js diff --git a/packages/block-library/src/navigation-menu-item/editor.scss b/packages/block-library/src/navigation-link/editor.scss similarity index 76% rename from packages/block-library/src/navigation-menu-item/editor.scss rename to packages/block-library/src/navigation-link/editor.scss index 759b7c45e9e495..e9260856ae3e58 100644 --- a/packages/block-library/src/navigation-menu-item/editor.scss +++ b/packages/block-library/src/navigation-link/editor.scss @@ -1,14 +1,14 @@ // Normalize menu items and edit containers, to look mostly the same. -.wp-block-navigation-menu-item__field .components-text-control__input.components-text-control__input, -.wp-block-navigation-menu-item__container { +.wp-block-navigation-link__field .components-text-control__input.components-text-control__input, +.wp-block-navigation-link__container { border-radius: 0; // Make it the same height as the appender to prevent a jump. Maybe revisit this. line-height: $icon-button-size; min-height: $icon-button-size; } -.wp-block-navigation-menu-item { +.wp-block-navigation-link { margin-right: $grid-size; .block-editor-block-list__layout { @@ -32,14 +32,14 @@ } } -.wp-block-navigation-menu-item__edit-container { +.wp-block-navigation-link__edit-container { display: flex; white-space: nowrap; // Compensate for menu item base padding. margin-left: -$grid-size; - .wp-block-navigation-menu-item__content { + .wp-block-navigation-link__content { margin-right: $grid-size; // This should match the padding of the menu item. @@ -63,13 +63,13 @@ } } -.wp-block-navigation-menu-item { +.wp-block-navigation-link { &.is-editing, &.is-selected { min-width: 20px; } - &.has-link .wp-block-navigation-menu-item__content { + &.has-link .wp-block-navigation-link__content { border-bottom-style: solid; border-bottom-width: 1px; } @@ -79,27 +79,27 @@ } } -.wp-block-navigation-menu-item__nofollow-external-link { +.wp-block-navigation-link__nofollow-external-link { display: block; } // Separator -.wp-block-navigation-menu-item__separator { +.wp-block-navigation-link__separator { margin: $grid-size 0 $grid-size; border-top: $border-width solid $light-gray-500; } // Popover styles -.components-popover:not(.is-mobile).wp-block-navigation-menu-item__dropdown-content { +.components-popover:not(.is-mobile).wp-block-navigation-link__dropdown-content { margin-top: -1px; margin-left: -4px; } -.wp-block-navigation-menu-item__dropdown-content .components-popover__content { +.wp-block-navigation-link__dropdown-content .components-popover__content { padding: $grid-size 0; } -.wp-block-navigation-menu .block-editor-block-list__block[data-type="core/navigation-menu-item"] { +.wp-block-navigation-menu .block-editor-block-list__block[data-type="core/navigation-link"] { & > .block-editor-block-list__insertion-point { display: none; } diff --git a/packages/block-library/src/navigation-menu-item/index.js b/packages/block-library/src/navigation-link/index.js similarity index 94% rename from packages/block-library/src/navigation-menu-item/index.js rename to packages/block-library/src/navigation-link/index.js index 30c5ecc26849c3..121fa70227acae 100644 --- a/packages/block-library/src/navigation-menu-item/index.js +++ b/packages/block-library/src/navigation-link/index.js @@ -16,7 +16,7 @@ export { metadata, name }; export const settings = { title: __( 'Navigation Link' ), - parent: [ 'core/navigation-link' ], + parent: [ 'core/navigation-menu' ], icon: , diff --git a/packages/block-library/src/navigation-menu-item/save.js b/packages/block-library/src/navigation-link/save.js similarity index 100% rename from packages/block-library/src/navigation-menu-item/save.js rename to packages/block-library/src/navigation-link/save.js diff --git a/packages/block-library/src/navigation-menu/edit.js b/packages/block-library/src/navigation-menu/edit.js index 15b71ebfc0d6f5..b6ee4435162140 100644 --- a/packages/block-library/src/navigation-menu/edit.js +++ b/packages/block-library/src/navigation-menu/edit.js @@ -91,7 +91,7 @@ function NavigationMenu( { // const handleCreateEmpty = () => { - const emptyNavItemBlock = createBlock( 'core/navigation-menu-item' ); + const emptyNavItemBlock = createBlock( 'core/navigation-link' ); updateNavItemBlocks( [ emptyNavItemBlock ] ); }; diff --git a/packages/block-library/src/navigation-menu/index.php b/packages/block-library/src/navigation-menu/index.php index 71a88da1a61b2f..729835c118a5a3 100644 --- a/packages/block-library/src/navigation-menu/index.php +++ b/packages/block-library/src/navigation-menu/index.php @@ -74,7 +74,7 @@ function render_block_navigation_menu( $attributes, $content, $block ) { */ function build_navigation_menu_html( $block, $colors ) { $html = ''; - foreach ( (array) $block['innerBlocks'] as $key => $menu_item ) { + foreach ( (array) $block['innerBlocks'] as $key => $block ) { $html .= '
  • ' . ' 0 ) { - $html .= build_navigation_menu_html( $menu_item, $colors ); + if ( count( (array) $block['innerBlocks'] ) > 0 ) { + $html .= build_navigation_menu_html( $block, $colors ); } $html .= '
  • '; diff --git a/packages/e2e-tests/fixtures/blocks/core__navigation-link.html b/packages/e2e-tests/fixtures/blocks/core__navigation-link.html new file mode 100644 index 00000000000000..d696e0cc0248e1 --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__navigation-link.html @@ -0,0 +1,2 @@ + + diff --git a/packages/e2e-tests/fixtures/blocks/core__navigation-menu-item.json b/packages/e2e-tests/fixtures/blocks/core__navigation-link.json similarity index 87% rename from packages/e2e-tests/fixtures/blocks/core__navigation-menu-item.json rename to packages/e2e-tests/fixtures/blocks/core__navigation-link.json index 4e5ae943cb9b4a..f0a50359a7a355 100644 --- a/packages/e2e-tests/fixtures/blocks/core__navigation-menu-item.json +++ b/packages/e2e-tests/fixtures/blocks/core__navigation-link.json @@ -1,7 +1,7 @@ [ { "clientId": "_clientId_0", - "name": "core/navigation-menu-item", + "name": "core/navigation-link", "isValid": true, "attributes": { "label": "WordPress", diff --git a/packages/e2e-tests/fixtures/blocks/core__navigation-menu-item.parsed.json b/packages/e2e-tests/fixtures/blocks/core__navigation-link.parsed.json similarity index 88% rename from packages/e2e-tests/fixtures/blocks/core__navigation-menu-item.parsed.json rename to packages/e2e-tests/fixtures/blocks/core__navigation-link.parsed.json index 2b03a8420038b8..a2e566639cc57d 100644 --- a/packages/e2e-tests/fixtures/blocks/core__navigation-menu-item.parsed.json +++ b/packages/e2e-tests/fixtures/blocks/core__navigation-link.parsed.json @@ -1,6 +1,6 @@ [ { - "blockName": "core/navigation-menu-item", + "blockName": "core/navigation-link", "attrs": { "label": "WordPress", "url": "https://wordpress.org/" diff --git a/packages/e2e-tests/fixtures/blocks/core__navigation-link.serialized.html b/packages/e2e-tests/fixtures/blocks/core__navigation-link.serialized.html new file mode 100644 index 00000000000000..0d7f09cb6df618 --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__navigation-link.serialized.html @@ -0,0 +1 @@ + diff --git a/packages/e2e-tests/fixtures/blocks/core__navigation-menu-item.html b/packages/e2e-tests/fixtures/blocks/core__navigation-menu-item.html deleted file mode 100644 index 0ad94205cbce05..00000000000000 --- a/packages/e2e-tests/fixtures/blocks/core__navigation-menu-item.html +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/packages/e2e-tests/fixtures/blocks/core__navigation-menu-item.serialized.html b/packages/e2e-tests/fixtures/blocks/core__navigation-menu-item.serialized.html deleted file mode 100644 index ecf1f0ce7ad654..00000000000000 --- a/packages/e2e-tests/fixtures/blocks/core__navigation-menu-item.serialized.html +++ /dev/null @@ -1 +0,0 @@ - From b8ec11683d6ea49d01ba4b372b6f1a253015c968 Mon Sep 17 00:00:00 2001 From: retrofox Date: Thu, 14 Nov 2019 16:32:31 -0300 Subject: [PATCH 03/11] e2e-tests: fix navigation-link test --- packages/e2e-tests/fixtures/block-transforms.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/e2e-tests/fixtures/block-transforms.js b/packages/e2e-tests/fixtures/block-transforms.js index 3a44a8b2e817bb..a1e865e1b33704 100644 --- a/packages/e2e-tests/fixtures/block-transforms.js +++ b/packages/e2e-tests/fixtures/block-transforms.js @@ -353,8 +353,8 @@ export const EXPECTED_TRANSFORMS = { 'Group', ], }, - 'core__navigation-menu-item': { - originalBlock: 'Menu Item', + 'core__navigation-link': { + originalBlock: 'Navigation Link', availableTransforms: [ 'Group', ], From 7edbc87ecd6e187b26c49df0dd28e003b0658bea Mon Sep 17 00:00:00 2001 From: retrofox Date: Mon, 11 Nov 2019 14:55:15 -0300 Subject: [PATCH 04/11] navigation-menu: render item withour link It handles the case when the item has not defined a linl, rendering the item with an element instrad of an anchor . --- .../src/navigation-link/editor.scss | 4 ++ .../src/navigation-menu/index.php | 49 ++++++++++--------- .../src/navigation-menu/style.scss | 3 +- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/packages/block-library/src/navigation-link/editor.scss b/packages/block-library/src/navigation-link/editor.scss index e9260856ae3e58..6dce65a908f6c4 100644 --- a/packages/block-library/src/navigation-link/editor.scss +++ b/packages/block-library/src/navigation-link/editor.scss @@ -30,6 +30,10 @@ &.is-editing .block-editor-inner-blocks { display: block; } + + .wp-block-navigation-menu-item__label { + cursor: default; + } } .wp-block-navigation-link__edit-container { diff --git a/packages/block-library/src/navigation-menu/index.php b/packages/block-library/src/navigation-menu/index.php index 729835c118a5a3..113e2b3c98cd99 100644 --- a/packages/block-library/src/navigation-menu/index.php +++ b/packages/block-library/src/navigation-menu/index.php @@ -75,37 +75,38 @@ function render_block_navigation_menu( $attributes, $content, $block ) { function build_navigation_menu_html( $block, $colors ) { $html = ''; foreach ( (array) $block['innerBlocks'] as $key => $block ) { - - $html .= '
  • ' . - '' . + ( isset( $block['attrs']['label'] ) ? $block['attrs']['label'] : '' ) . + ''; + } else { + $item_content_markup = + '' . + ( isset( $block['attrs']['label'] ) ? $block['attrs']['label'] : '' ) . + ''; } - if ( isset( $block['attrs']['opensInNewTab'] ) && true === $block['attrs']['opensInNewTab'] ) { - $html .= ' target="_blank" '; - } - // End appending HTML attributes to anchor tag. - - // Start anchor tag content. - $html .= '>'; - if ( isset( $block['attrs']['label'] ) ) { - $html .= $block['attrs']['label']; - } - $html .= ''; - // End anchor tag content. + $html .= + '
  • ' . + $item_content_markup; if ( count( (array) $block['innerBlocks'] ) > 0 ) { $html .= build_navigation_menu_html( $block, $colors ); } - $html .= '
  • '; } return '
      ' . $html . '
    '; diff --git a/packages/block-library/src/navigation-menu/style.scss b/packages/block-library/src/navigation-menu/style.scss index 16900caf4cc6bb..2b677d24bfcb03 100644 --- a/packages/block-library/src/navigation-menu/style.scss +++ b/packages/block-library/src/navigation-menu/style.scss @@ -80,7 +80,8 @@ } // Menu Link - a { + a, + span { display: block; padding: 16px; } From 0f726b6ccba0f65a6d3635bd63c695e2164b2eb9 Mon Sep 17 00:00:00 2001 From: retrofox Date: Wed, 13 Nov 2019 10:25:10 -0300 Subject: [PATCH 05/11] navigation-menu: fix unclosing quote --- packages/block-library/src/navigation-menu/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/navigation-menu/index.php b/packages/block-library/src/navigation-menu/index.php index 113e2b3c98cd99..10e9607cc27dd2 100644 --- a/packages/block-library/src/navigation-menu/index.php +++ b/packages/block-library/src/navigation-menu/index.php @@ -81,7 +81,7 @@ function build_navigation_menu_html( $block, $colors ) { ' Date: Wed, 13 Nov 2019 10:41:52 -0300 Subject: [PATCH 06/11] navigation-menu: escape all html attrs --- .../src/navigation-menu/index.php | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/block-library/src/navigation-menu/index.php b/packages/block-library/src/navigation-menu/index.php index 10e9607cc27dd2..d7fdfa7d24d8a2 100644 --- a/packages/block-library/src/navigation-menu/index.php +++ b/packages/block-library/src/navigation-menu/index.php @@ -75,20 +75,22 @@ function render_block_navigation_menu( $attributes, $content, $block ) { function build_navigation_menu_html( $block, $colors ) { $html = ''; foreach ( (array) $block['innerBlocks'] as $key => $block ) { + $title = isset( $block['attrs']['title'] ) ? esc_attr( $block['attrs']['title'] ) : ''; + $label = isset( $block['attrs']['label'] ) ? esc_attr( $block['attrs']['label'] ) : ''; + $url = isset( $block['attrs']['url'] ) ? esc_attr( $block['attrs']['url'] ) : ''; + $opens_in_new_tab = isset( $block['attrs']['opensInNewTab'] ) && true === $block['attrs']['opensInNewTab']; + // Creates the markup for the item content element. if ( isset( $block['attrs']['url'] ) ) { $item_content_markup = '' . - ( isset( $block['attrs']['label'] ) ? $block['attrs']['label'] : '' ) . + ( isset( $block['attrs']['label'] ) ? $label : '' ) . ''; } else { $item_content_markup = @@ -96,13 +98,11 @@ class="wp-block-navigation-menu-item__link ' . $colors['text_css_classes'] . '" class="wp-block-navigation-menu-item__label ' . $colors['text_css_classes'] . '" ' . $colors['text_inline_styles'] . '>' . - ( isset( $block['attrs']['label'] ) ? $block['attrs']['label'] : '' ) . + ( isset( $block['attrs']['label'] ) ? $label : '' ) . ''; } - $html .= - '
  • ' . - $item_content_markup; + $html .= '
  • ' . $item_content_markup; if ( count( (array) $block['innerBlocks'] ) > 0 ) { $html .= build_navigation_menu_html( $block, $colors ); From fe23ae3ace6bc44e06cd31904d1ba2f35cb6dde2 Mon Sep 17 00:00:00 2001 From: retrofox Date: Wed, 13 Nov 2019 10:45:34 -0300 Subject: [PATCH 07/11] navigation-menu: fix lint-php errors --- packages/block-library/src/navigation-menu/index.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/block-library/src/navigation-menu/index.php b/packages/block-library/src/navigation-menu/index.php index d7fdfa7d24d8a2..7919bbf74e6234 100644 --- a/packages/block-library/src/navigation-menu/index.php +++ b/packages/block-library/src/navigation-menu/index.php @@ -75,9 +75,9 @@ function render_block_navigation_menu( $attributes, $content, $block ) { function build_navigation_menu_html( $block, $colors ) { $html = ''; foreach ( (array) $block['innerBlocks'] as $key => $block ) { - $title = isset( $block['attrs']['title'] ) ? esc_attr( $block['attrs']['title'] ) : ''; - $label = isset( $block['attrs']['label'] ) ? esc_attr( $block['attrs']['label'] ) : ''; - $url = isset( $block['attrs']['url'] ) ? esc_attr( $block['attrs']['url'] ) : ''; + $title = isset( $block['attrs']['title'] ) ? esc_attr( $block['attrs']['title'] ) : ''; + $label = isset( $block['attrs']['label'] ) ? esc_attr( $block['attrs']['label'] ) : ''; + $url = isset( $block['attrs']['url'] ) ? esc_attr( $block['attrs']['url'] ) : ''; $opens_in_new_tab = isset( $block['attrs']['opensInNewTab'] ) && true === $block['attrs']['opensInNewTab']; // Creates the markup for the item content element. @@ -88,7 +88,7 @@ class="wp-block-navigation-menu-item__link ' . $colors['text_css_classes'] . '" ' . $colors['text_inline_styles'] . ' href="' . $url . '"' . ( $block['attrs']['title'] ? ( ' title="' . $title . '"' ) : '' ) . - ( $opens_in_new_tab? ' target="_blank"' : '' ) . + ( $opens_in_new_tab ? ' target="_blank"' : '' ) . '>' . ( isset( $block['attrs']['label'] ) ? $label : '' ) . ''; From e9e115817fbcc415f7146c04267fa4724a6835bb Mon Sep 17 00:00:00 2001 From: retrofox Date: Wed, 13 Nov 2019 11:59:05 -0300 Subject: [PATCH 08/11] navigation-menu: remove unused CSS. Rename class --- packages/block-library/src/navigation-link/editor.scss | 4 ---- packages/block-library/src/navigation-menu/index.php | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/block-library/src/navigation-link/editor.scss b/packages/block-library/src/navigation-link/editor.scss index 6dce65a908f6c4..e9260856ae3e58 100644 --- a/packages/block-library/src/navigation-link/editor.scss +++ b/packages/block-library/src/navigation-link/editor.scss @@ -30,10 +30,6 @@ &.is-editing .block-editor-inner-blocks { display: block; } - - .wp-block-navigation-menu-item__label { - cursor: default; - } } .wp-block-navigation-link__edit-container { diff --git a/packages/block-library/src/navigation-menu/index.php b/packages/block-library/src/navigation-menu/index.php index 7919bbf74e6234..9b30bee9db5b38 100644 --- a/packages/block-library/src/navigation-menu/index.php +++ b/packages/block-library/src/navigation-menu/index.php @@ -95,7 +95,7 @@ class="wp-block-navigation-menu-item__link ' . $colors['text_css_classes'] . '" } else { $item_content_markup = '' . ( isset( $block['attrs']['label'] ) ? $label : '' ) . From 591635f9cc9add120142c26d0d99aac8e298ab57 Mon Sep 17 00:00:00 2001 From: retrofox Date: Wed, 13 Nov 2019 12:12:32 -0300 Subject: [PATCH 09/11] navigation-menu: simplify making the markup --- packages/block-library/src/navigation-menu/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/navigation-menu/index.php b/packages/block-library/src/navigation-menu/index.php index 9b30bee9db5b38..12cf29b0c32423 100644 --- a/packages/block-library/src/navigation-menu/index.php +++ b/packages/block-library/src/navigation-menu/index.php @@ -87,10 +87,10 @@ function build_navigation_menu_html( $block, $colors ) { class="wp-block-navigation-menu-item__link ' . $colors['text_css_classes'] . '" ' . $colors['text_inline_styles'] . ' href="' . $url . '"' . - ( $block['attrs']['title'] ? ( ' title="' . $title . '"' ) : '' ) . + ( $title ? ' title="' . $title . '"' : '' ) . ( $opens_in_new_tab ? ' target="_blank"' : '' ) . '>' . - ( isset( $block['attrs']['label'] ) ? $label : '' ) . + ( $label ? $label : '' ) . ''; } else { $item_content_markup = From 62be3c9fba5ac0b20e628971f617cd45ddec9338 Mon Sep 17 00:00:00 2001 From: retrofox Date: Wed, 13 Nov 2019 12:22:09 -0300 Subject: [PATCH 10/11] navigation-menu: set tezxt item styles --- packages/block-library/src/navigation-menu/style.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/navigation-menu/style.scss b/packages/block-library/src/navigation-menu/style.scss index 2b677d24bfcb03..475311a4340de3 100644 --- a/packages/block-library/src/navigation-menu/style.scss +++ b/packages/block-library/src/navigation-menu/style.scss @@ -81,7 +81,7 @@ // Menu Link a, - span { + .wp-block-navigation-menu-item__text { display: block; padding: 16px; } From 8c5bc3637c8136afb73797d34be42500f1659b90 Mon Sep 17 00:00:00 2001 From: retrofox Date: Thu, 14 Nov 2019 10:00:06 -0300 Subject: [PATCH 11/11] navigation-menu: simply setting item label --- packages/block-library/src/navigation-menu/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/navigation-menu/index.php b/packages/block-library/src/navigation-menu/index.php index 12cf29b0c32423..a5ea49fa7d5a0d 100644 --- a/packages/block-library/src/navigation-menu/index.php +++ b/packages/block-library/src/navigation-menu/index.php @@ -90,7 +90,7 @@ class="wp-block-navigation-menu-item__link ' . $colors['text_css_classes'] . '" ( $title ? ' title="' . $title . '"' : '' ) . ( $opens_in_new_tab ? ' target="_blank"' : '' ) . '>' . - ( $label ? $label : '' ) . + $label . ''; } else { $item_content_markup = @@ -98,7 +98,7 @@ class="wp-block-navigation-menu-item__link ' . $colors['text_css_classes'] . '" class="wp-block-navigation-menu-item__text ' . $colors['text_css_classes'] . '" ' . $colors['text_inline_styles'] . '>' . - ( isset( $block['attrs']['label'] ) ? $label : '' ) . + $label . ''; }