Skip to content

Commit

Permalink
Format library: link: remove aria-label (#18742)
Browse files Browse the repository at this point in the history
* Format library: link: remove aria-label

* Adjust new e2e snap
  • Loading branch information
ellatrix authored Feb 13, 2020
1 parent 9d67638 commit c84784f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exports[`Links can be created by selecting text and using keyboard shortcuts 1`]
exports[`Links can be created by selecting text and using keyboard shortcuts 2`] = `
"<!-- wp:paragraph -->
<p>This is <a href=\\"https://wordpress.org/gutenberg\\" target=\\"_blank\\" rel=\\"noreferrer noopener\\" aria-label=\\"Gutenberg (opens in a new tab)\\">Gutenberg</a></p>
<p>This is <a href=\\"https://wordpress.org/gutenberg\\" target=\\"_blank\\" rel=\\"noreferrer noopener\\">Gutenberg</a></p>
<!-- /wp:paragraph -->"
`;
Expand Down 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

0 comments on commit c84784f

Please sign in to comment.