Skip to content

Format Library: Link aria-label is assigned wrong text #12325

@aduth

Description

@aduth

Introduced in #11063
Previously: #11815 (comment)

Steps to reproduce:

  1. Navigate to Posts > Add New
  2. Add a paragraph with at least a few words
  3. Apply a link to some but not all of the text, enabling the open in New Tab option
  4. Verify generated HTML in Code Editor

Expected:

<!-- wp:paragraph -->
<p>this is a <a href="http://example.com" target="_blank" rel="noreferrer noopener" aria-label="test (opens in a new tab)">test</a></p>
<!-- /wp:paragraph -->

Actual:

<!-- wp:paragraph -->
<p>this is a <a href="http://example.com" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">test</a></p>
<!-- /wp:paragraph -->

(the text of the link, with "(opens in new tab)" appended as a suffix)

Observations:

Relevant code:

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 ).trim();
format.attributes.target = '_blank';
format.attributes.rel = 'noreferrer noopener';
format.attributes[ 'aria-label' ] = label;
}

cc @ryanwelcher @mcsf

Metadata

Metadata

Assignees

Labels

Needs Accessibility FeedbackNeed input from accessibilityNeeds DecisionNeeds a decision to be actionable or relevant[Focus] Accessibility (a11y)Changes that impact accessibility and need corresponding review (e.g. markup changes).[Package] Format library/packages/format-library[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions