Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Format library: link: remove aria-label
  • Loading branch information
ellatrix committed Feb 13, 2020
commit f562ab286900d41a89f50a8ce630168350245399
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ exports[`Links can be removed 1`] = `

exports[`Links should contain a label when it should open in a new tab 1`] = `
"<!-- wp:paragraph -->
<p>This is <a href=\\"http://w.org\\" target=\\"_blank\\" rel=\\"noreferrer noopener\\" aria-label=\\"WordPress (opens in a new tab)\\">WordPress</a></p>
<p>This is <a href=\\"http://w.org\\" target=\\"_blank\\" rel=\\"noreferrer noopener\\">WordPress</a></p>
<!-- /wp:paragraph -->"
`;

Expand Down
11 changes: 1 addition & 10 deletions packages/format-library/src/link/inline.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,7 @@ import { useMemo, useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { withSpokenMessages, Popover } from '@wordpress/components';
import { prependHTTP } from '@wordpress/url';
import {
create,
insert,
isCollapsed,
applyFormat,
getTextContent,
slice,
} from '@wordpress/rich-text';
import { create, insert, isCollapsed, applyFormat } from '@wordpress/rich-text';
import { __experimentalLinkControl as LinkControl } from '@wordpress/block-editor';

/**
Expand Down Expand Up @@ -120,11 +113,9 @@ function InlineLinkUI( {
}

const newUrl = prependHTTP( nextValue.url );
const selectedText = getTextContent( slice( value ) );
const format = createLinkFormat( {
url: newUrl,
opensInNewWindow: nextValue.opensInNewTab,
text: selectedText,
} );

if ( isCollapsed( value ) && ! isActive ) {
Expand Down
7 changes: 1 addition & 6 deletions packages/format-library/src/link/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
getFragment,
isValidFragment,
} from '@wordpress/url';
import { __, sprintf } from '@wordpress/i18n';

/**
* Check for issues with the provided href.
Expand Down Expand Up @@ -93,7 +92,7 @@ export function isValidHref( href ) {
*
* @return {Object} The final format object.
*/
export function createLinkFormat( { url, opensInNewWindow, text } ) {
export function createLinkFormat( { url, opensInNewWindow } ) {
const format = {
type: 'core/link',
attributes: {
Expand All @@ -102,12 +101,8 @@ export function createLinkFormat( { url, opensInNewWindow, text } ) {
};

if ( opensInNewWindow ) {
// translators: accessibility label for external links, where the argument is the link text
const label = sprintf( __( '%s (opens in a new tab)' ), text );

format.attributes.target = '_blank';
format.attributes.rel = 'noreferrer noopener';
format.attributes[ 'aria-label' ] = label;
}

return format;
Expand Down