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 Jan 31, 2020
1 parent 539b1fc commit b2423f9
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 25 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
15 changes: 2 additions & 13 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 } from 'lodash';
import { escape } from 'lodash';

/**
* WordPress dependencies
Expand All @@ -16,7 +16,6 @@ import {
PanelBody,
Popover,
TextareaControl,
TextControl,
ToggleControl,
ToolbarButton,
ToolbarGroup,
Expand Down Expand Up @@ -46,9 +45,8 @@ function NavigationLinkEdit( {
showSubmenuIcon,
insertLinkBlock,
} ) {
const { label, opensInNewTab, title, url, nofollow, description } = attributes;
const { label, opensInNewTab, url, nofollow, description } = attributes;
const link = {
title: title ? unescape( title ) : '',
url,
opensInNewTab,
};
Expand Down Expand Up @@ -92,14 +90,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 @@ -165,7 +155,6 @@ function NavigationLinkEdit( {
id,
} = {} ) =>
setAttributes( {
title: escape( newTitle ),
url: encodeURI( newURL ),
label: ( () => {
const normalizedTitle = newTitle.replace( /http(s?):\/\//gi, '' );
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 @@ -94,7 +94,6 @@ function Navigation( {
id,
url,
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 build_navigation_html( $attributes, $block, $colors, $font_sizes, $is_l
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 b2423f9

Please sign in to comment.