From c84784ff5037b4f859f2d30ac5487cca2f95dacf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ella=20van=C2=A0Durpe?= Date: Thu, 13 Feb 2020 13:32:02 +0100 Subject: [PATCH] Format library: link: remove aria-label (#18742) * Format library: link: remove aria-label * Adjust new e2e snap --- .../editor/various/__snapshots__/links.test.js.snap | 4 ++-- packages/format-library/src/link/inline.js | 11 +---------- packages/format-library/src/link/utils.js | 7 +------ 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/packages/e2e-tests/specs/editor/various/__snapshots__/links.test.js.snap b/packages/e2e-tests/specs/editor/various/__snapshots__/links.test.js.snap index cf6bb746c56033..330dfbbe142b08 100644 --- a/packages/e2e-tests/specs/editor/various/__snapshots__/links.test.js.snap +++ b/packages/e2e-tests/specs/editor/various/__snapshots__/links.test.js.snap @@ -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`] = ` " -

This is Gutenberg

+

This is Gutenberg

" `; @@ -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`] = ` " -

This is WordPress

+

This is WordPress

" `; diff --git a/packages/format-library/src/link/inline.js b/packages/format-library/src/link/inline.js index 2d9eb18df15783..827e6652e4025a 100644 --- a/packages/format-library/src/link/inline.js +++ b/packages/format-library/src/link/inline.js @@ -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'; /** @@ -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 ) { diff --git a/packages/format-library/src/link/utils.js b/packages/format-library/src/link/utils.js index ed22d57b24a022..d57cb03b2f6d1c 100644 --- a/packages/format-library/src/link/utils.js +++ b/packages/format-library/src/link/utils.js @@ -18,7 +18,6 @@ import { getFragment, isValidFragment, } from '@wordpress/url'; -import { __, sprintf } from '@wordpress/i18n'; /** * Check for issues with the provided href. @@ -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: { @@ -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;