Skip to content

Commit

Permalink
Block Library: Navigation: Remove title attribute from navigation link
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Feb 5, 2020
1 parent 15eb6d0 commit 2a187c8
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 34 deletions.
3 changes: 0 additions & 3 deletions packages/block-library/src/navigation-link/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
"type": "boolean",
"default": false
},
"title": {
"type": "string"
},
"type": {
"type": "string"
},
Expand Down
24 changes: 2 additions & 22 deletions packages/block-library/src/navigation-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import classnames from 'classnames';
import { escape, unescape, head } from 'lodash';
import { escape, head } from 'lodash';

/**
* WordPress dependencies
Expand All @@ -16,7 +16,6 @@ import {
PanelBody,
Popover,
TextareaControl,
TextControl,
ToggleControl,
ToolbarButton,
ToolbarGroup,
Expand Down Expand Up @@ -48,14 +47,7 @@ function NavigationLinkEdit( {
insertLinkBlock,
navigationBlockAttributes,
} ) {
const {
label,
opensInNewTab,
title,
url,
nofollow,
description,
} = attributes;
const { label, opensInNewTab, url, nofollow, description } = attributes;

/*
* Navigation Block attributes.
Expand All @@ -68,7 +60,6 @@ function NavigationLinkEdit( {
} = navigationBlockAttributes;

const link = {
title: title ? unescape( title ) : '',
url,
opensInNewTab,
};
Expand Down Expand Up @@ -157,16 +148,6 @@ function NavigationLinkEdit( {
</BlockControls>
<InspectorControls>
<PanelBody title={ __( 'SEO settings' ) }>
<TextControl
value={ title || '' }
onChange={ ( titleValue ) => {
setAttributes( { title: titleValue } );
} }
label={ __( 'Title Attribute' ) }
help={ __(
'Provide more context about where the link goes.'
) }
/>
<ToggleControl
checked={ nofollow }
onChange={ ( nofollowValue ) => {
Expand Down Expand Up @@ -258,7 +239,6 @@ function NavigationLinkEdit( {
id,
} = {} ) =>
setAttributes( {
title: escape( newTitle ),
url: encodeURI( newURL ),
label: ( () => {
const normalizedTitle = newTitle.replace(
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/navigation/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ function Navigation( {
label: ! title.rendered
? __( '(no title)' )
: escape( title.rendered ),
title: ! title.raw ? __( '(no title)' ) : escape( title.raw ),
opensInNewTab: false,
} )
);
Expand Down
3 changes: 0 additions & 3 deletions packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,6 @@ function core_block_navigation_build_html( $attributes, $block, $colors, $font_s
if ( isset( $block['attrs']['url'] ) ) {
$html .= ' href="' . esc_url( $block['attrs']['url'] ) . '"';
}
if ( isset( $block['attrs']['title'] ) ) {
$html .= ' title="' . esc_attr( $block['attrs']['title'] ) . '"';
}

if ( isset( $block['attrs']['opensInNewTab'] ) && true === $block['attrs']['opensInNewTab'] ) {
$html .= ' target="_blank" ';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

exports[`Navigation allows a navigation menu to be created from an empty menu using a mixture of internal and external links 1`] = `
"<!-- wp:navigation -->
<!-- wp:navigation-link {\\"label\\":\\"WP\\",\\"title\\":\\"https://wordpress.org\\",\\"id\\":\\"-1\\",\\"url\\":\\"https://wordpress.org\\"} /-->
<!-- wp:navigation-link {\\"label\\":\\"WP\\",\\"id\\":\\"-1\\",\\"url\\":\\"https://wordpress.org\\"} /-->
<!-- wp:navigation-link {\\"label\\":\\"Get in touch\\",\\"title\\":\\"Contact Us\\",\\"id\\":1,\\"url\\":\\"https://this/is/a/test/url/contact-us\\"} /-->
<!-- wp:navigation-link {\\"label\\":\\"Get in touch\\",\\"id\\":1,\\"url\\":\\"https://this/is/a/test/url/contact-us\\"} /-->
<!-- /wp:navigation -->"
`;

exports[`Navigation allows a navigation menu to be created using existing pages 1`] = `
"<!-- wp:navigation -->
<!-- wp:navigation-link {\\"label\\":\\"Home\\",\\"title\\":\\"Home\\",\\"type\\":\\"page\\",\\"id\\":1,\\"url\\":\\"https://this/is/a/test/url/home\\"} /-->
<!-- wp:navigation-link {\\"label\\":\\"Home\\",\\"type\\":\\"page\\",\\"id\\":1,\\"url\\":\\"https://this/is/a/test/url/home\\"} /-->
<!-- wp:navigation-link {\\"label\\":\\"About\\",\\"title\\":\\"About\\",\\"type\\":\\"page\\",\\"id\\":2,\\"url\\":\\"https://this/is/a/test/url/about\\"} /-->
<!-- wp:navigation-link {\\"label\\":\\"About\\",\\"type\\":\\"page\\",\\"id\\":2,\\"url\\":\\"https://this/is/a/test/url/about\\"} /-->
<!-- wp:navigation-link {\\"label\\":\\"Contact Us\\",\\"title\\":\\"Contact Us\\",\\"type\\":\\"page\\",\\"id\\":3,\\"url\\":\\"https://this/is/a/test/url/contact\\"} /-->
<!-- wp:navigation-link {\\"label\\":\\"Contact Us\\",\\"type\\":\\"page\\",\\"id\\":3,\\"url\\":\\"https://this/is/a/test/url/contact\\"} /-->
<!-- /wp:navigation -->"
`;

0 comments on commit 2a187c8

Please sign in to comment.