Problem/Motivation

External links aren't using properly the aria-label, so assistive technology browsers aren't reading properly the label. This is an accessibility issue that is raised by automatic testing tools like e.g. Lighthouse.

Steps to reproduce

Add a external link. Check the Lighthouse tab in Google Chrome.

Proposed resolution

#0 proposes removing the aria-label.
#4 proposes moving aria-label into link wrapping element and adding role=img and aria-hidden=true to icon span.

Remaining tasks

Decide which one works best.

User interface changes

None for visual browsers.
Corrected screen reader (i.e. VoiceOver in this case) for assistive technology browsers.

API changes

None.

Data model changes

None.

Original Report

Users of screen readers and other assistive technologies get information by HTML code like label or aria attributes. If the HTML tag and attributes doesn’t match, screen reader will not be able to get the correct information. And users will be confused and feel difficulty in viewing our site.

Issue fork extlink-3275748

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

randy Tang created an issue. See original summary.

morganlyndel’s picture

Status: Active » Reviewed & tested by the community

I tested this patch on an environment that had previously been receiving the "`[aria-*]` attributes do not match their roles" error and confirm that this error went away once the patch was applied.

Steps to test:

  • Discover the "`[aria-*]` attributes do not match their roles" error on a site during a Lighthouse scan (recreate the error).
  • Download the patch attached to this issue and apply it using composer.
  • Clear the cache, then re-run the Lighthouse scan on the offending page.
  • Confirm that the error is no longer present on the site.

Thank you!

chris matthews’s picture

Version: 8.x-1.6 » 8.x-1.x-dev
pivica’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.5 KB

Checked related documentation for this. Removing aria-label will fix this issue, but information in that label is lost, and it is not used at all any more. So if we want to go this route then we should also remove extlink_label and extlink_mailto_label configurations.

Instead of this we can move aria-label to link wrapper, as suggested in section 'aria-label in links'.

Then for font icons we should use role="img" and aria-hidden="true" as suggested in 'Simple approach' and 'Visual but accessible icon' and Semantically identifying a font icon with role="img".

With this new approach the assistive technology browser will ignore the icon and will read the link like "link Drupal link is external".

Instead of moving aria-label to a link tag, we could also leave it in a span, add a new span and hide it with visually-hidden CSS rule. For me aria-label looks as a more elegant solution.

Here is a patch with a new approach.

smustgrave’s picture

Status: Needs review » Needs work

Can the issue summary be updated using standard template.

smustgrave’s picture

Status: Needs work » Postponed (maintainer needs more info)

Need an issue summary update to understand what's being fixed exactly.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)
penyaskito’s picture

Issue summary: View changes
Status: Closed (outdated) » Needs work

Re-opening and did my best with issue summary. This is still an issue, and we have been using patch at #0 in production for a long time.

penyaskito’s picture

Issue tags: +a11y, +Accessibility
katannshaw’s picture

Issue summary: View changes

Added "Related WCAG success criteria and techniques" to issue description to provide context and clarity.

pivica’s picture

Issue summary: View changes
pivica’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Status: Needs work » Needs review
StatusFileSize
new3.71 KB
new3.79 KB

Updated patch from #4 against latest 2.0.x-dev. There were quite a few changes from 8.x-1.x-dev JS version of the code. I've also reused `drupalSettings.data.extlink.extHideIcons` option for aria-hidden value as the code is already doing it for embedded images.

Attaching also patch version for 2.0.0-beta1 version so we can use this with composer build easily.

smustgrave’s picture

Status: Needs review » Needs work

Changes should be in MRs please

pivica’s picture

Title: `[aria-*]` attributes do not match their roles » `[aria-*]` attributes do not match their roles when using FA icons
pivica’s picture

Status: Needs work » Needs review

MR created.

  • smustgrave committed c9497631 on 2.0.x
    Issue #3275748 by pivica, randy Tang, penyaskito, morganlyndel,...
smustgrave’s picture

Status: Needs review » Fixed

pivica’s picture

Status: Fixed » Needs review
StatusFileSize
new3.71 KB

Sorry, needs to reopen this because I introduced a small bug in previous MR. There is a double quote bug for a tel element on line 362:

iconElement.innerHTML = `<span class="${drupalSettings.data.extlink.extFaTelClasses}" data-extlink-placement="${iconPlacement}""></span>`;

New MR !35 should fix this.

Also attaching a updated patch for 2.0.0-beta1.

smustgrave’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.