Problem/Motivation

The external link module adds a visual indicator that a link is external. To create this same experience for an unsighted user, there needs to be some screen-reader only text that serves the same purpose. This text should be something like <span class="sr-only">Link is external</span>.

Additionally, accessibility standards require that people are warned when a link will open a new window.

This module offers the ability to force external links to open in new windows, but when that option is selected, we also need to add a warning about this behavior. Because new windows can be hard to navigate with screen-readers, many people would prefer not to click the link if there is a chance they can't get back to the originating site.

Proposed resolution

When the option to force links to open in new windows IS NOT selected

<a href="https://bayareametro.zoom.us/j/85868739599" rel="nofollow noopener noreferrer" class="ext" data-extlink="">
   Attend on Zoom
  <span class="fa-ext extlink">
    <span class="fa fa-external-link"></span>
    <span class="sr-only">Link is external.</span>
  </span>
</a>

When the option to force links to open in new windows IS selected

<a href="https://bayareametro.zoom.us/j/85868739599" rel="nofollow noopener noreferrer" class="ext" data-extlink="" target="_blank">
   Attend on Zoom
  <span class="fa-ext extlink">
    <span class="fa fa-external-link"></span>
    <span class="sr-only">link is external, and opens a new window.</span>
  </span>
</a>

Original Issue Summary

Hello,

Working on a project very concerned with the accessibility and using the module external link, I had to create a feature for the screen reader to tell for each external link of the site that it will open in a new window .

I will upload the patch regarding this feature.

Issue fork extlink-3054538

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

Piegefull created an issue. See original summary.

Piegefull’s picture

Status: Active » Needs review
StatusFileSize
new1.07 KB
grimreaper’s picture

Status: Needs review » Needs work

Hello,

+++ b/extlink.js
@@ -203,6 +203,18 @@
+        if(old_title.indexOf('New window') === -1){

The translated string needs to be tested.

Also whitespace before and after parenthesis.

+++ b/extlink.js
@@ -203,6 +203,18 @@
+      // Add to the title attr of ext link a 'New window' value for screen reader.

In comment, use the whole word "attribute" and not "attr".

grimreaper’s picture

Issue tags: +Accessibility

Tagging the issue.

Piegefull’s picture

StatusFileSize
new1.09 KB

Nice one,

Here is the fix for the patch.

grimreaper’s picture

Status: Needs work » Reviewed & tested by the community

Good for me except checkstyles.

timwood’s picture

Status: Reviewed & tested by the community » Needs work

The patch from #5 doesn't appear to check against the ExtLink module's 'Open external links in a new window.' setting before applying title="(New window)" to the link <a> tag. It should probably check for that since if that option isn't enabled, the link doesn't open in a new window.

Piegefull’s picture

Assigned: Unassigned » Piegefull
Status: Needs work » Needs review
Issue tags: +Smile Contribution Tour 2019
StatusFileSize
new1.18 KB

Sorry for the wait,

Here is the new patch with the verification for the link attr "target" === "_blank".

grimreaper’s picture

Queeing tests on a more recent PHP version.

grimreaper’s picture

Status: Needs review » Needs work

@Piegefull: Patch needs to be updated. I can help if you need it :).

alison’s picture

I feel like this should be an optional setting -- personally. Like, there are other ways to provide this info for WA purposes -- WCAG recommends putting it in the link text, which I realize is closely related to the title attribute, BUT, I really think this should be an optional setting :-/

(...but I don't have time to help with the code! Just sharing my two cents, I appreciate y'all's efforts.)

alison’s picture

One of my colleagues on our WA team said that some screen readers ignore the title attribute -- and even if the software doesn't ignore it, screen reader users often do, because it's read after the link text (so by the time it gets to the title attribute, they've already "clicked" (or not clicked)).

**Either way,** as I'm thinking/typing, I think that whatever is implemented, there should be a reference to the relevant WA guidelines/rules/etc. -- not necessarily the WCAG link I shared, someone else might have a better reference, but it should be in the issue description and release notes/changelog. (Do citation-ish links like that go into code comments, too, or not usually? Idk what the normal practice is.)

grimreaper’s picture

Version: 8.x-1.1 » 8.x-1.x-dev
Assigned: Piegefull » grimreaper
Status: Needs work » Needs review
Issue tags: +DrupalCon Amsterdam 2019
StatusFileSize
new11.43 KB

Hello,

Here is an updated version of patch from comment 8.

Now there is a dedicated option, an update hook and a dedicated test.

Unfortunately, my environment does not currently allows me to have Javascript tests working.

So we will see with testbot.

grimreaper’s picture

Assigned: grimreaper » Unassigned
brucedarby’s picture

I'm picking this up at DrupalCon Amsterdam.

brucedarby’s picture

Assigned: Unassigned » brucedarby
scuba_fly’s picture

Helping with this issue as mentor on Drupalcon Amsterdam 2019

petr illek’s picture

YAY! First time mentoring at DrupalCon Amsterdam 2019.

jwlockhart’s picture

Helping with this issue at DrupalCon Amsterdam 2019

brucedarby’s picture

Status: Needs review » Needs work

Patch applied ok but found an issue when trying to change the configuration of the module. When you check 'Open external links in a new window.' another option appears 'Add "(New window)" in the title of links that should open in new window.'. After checking this and saving the 'Add (New Window)' option unchecks. So the save does not persist.

I'm presuming this is the required actions to test this properly? Apologies if I've picked this up wrong?

Also when viewing the page we then got a JS error in Drupal.js:

drupal.js?v=8.7.8:13 Uncaught TypeError: $link[icon_placement] is not a function
    at Object.Drupal.extlink.applyClassAndSpan (extlink.js?v=8.7.8:220)
    at Object.Drupal.extlink.attach (extlink.js?v=8.7.8:107)
    at Object.Drupal.behaviors.extlink.attach (extlink.js?v=8.7.8:249)
    at drupal.js?v=8.7.8:25
    at Array.forEach (<anonymous>)
    at Object.Drupal.attachBehaviors (drupal.js?v=8.7.8:22)
    at drupal.init.js?v=8.7.8:16
    at HTMLDocument.t (ready.min.js?v=1.0.8:4)
brucedarby’s picture

Assigned: brucedarby » Unassigned
rachel_norfolk’s picture

Issue tags: -DrupalCon Amsterdam 2019 +Amsterdam2019

retagging

elachlan’s picture

I fixed the testing issue. But now the tests aren't passing.

elachlan’s picture

Could someone please reroll this patch?

andreyjan’s picture

Status: Needs work » Needs review
StatusFileSize
new13.19 KB

Rerolled the patch.

Status: Needs review » Needs work

The last submitted patch, 25: 3054538-25.patch, failed testing. View results

andreyjan’s picture

Status: Needs work » Needs review
StatusFileSize
new13.13 KB
new698 bytes

Removing the failing line $this->assertSession()->statusCodeEquals(200);. I don't think it's really needed in this test.

Status: Needs review » Needs work

The last submitted patch, 27: 3054538-27.patch, failed testing. View results

neslee canil pinto’s picture

Issue tags: +Needs reroll

Patch got failed, Needs a reroll

sahana _n’s picture

Status: Needs work » Needs review
StatusFileSize
new7.26 KB

Please review the patch.

Status: Needs review » Needs work

The last submitted patch, 30: 3054538-30.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

suresh prabhu parkala’s picture

Status: Needs work » Needs review
StatusFileSize
new7.14 KB

Please review!

Status: Needs review » Needs work

The last submitted patch, 32: 3054538-32.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

suresh prabhu parkala’s picture

Status: Needs work » Needs review
StatusFileSize
new7.23 KB

Please review!

Status: Needs review » Needs work

The last submitted patch, 34: 3054538-34.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

suresh prabhu parkala’s picture

Status: Needs work » Needs review
StatusFileSize
new803 bytes
new7.22 KB

Please review.

Status: Needs review » Needs work

The last submitted patch, 36: 3054538-36.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

suresh prabhu parkala’s picture

Status: Needs work » Needs review
StatusFileSize
new7.23 KB
new1.68 KB

please review the patch.

Status: Needs review » Needs work

The last submitted patch, 38: 3054538-38.patch, failed testing. View results

rahulrasgon’s picture

Assigned: Unassigned » rahulrasgon
rahulrasgon’s picture

Assigned: rahulrasgon » Unassigned
Status: Needs work » Needs review
StatusFileSize
new8.02 KB
new2.91 KB

Please review the patch.

Thanks

wendymc’s picture

I've applied the patch from #41 but external links still do not have a title attribute.

Thank you for the effort to make this more accessible!

edwardchiapet’s picture

I've rerolled #41 for 8.x-1.7.

prudloff’s picture

StatusFileSize
new8.2 KB
new654 bytes

#43 adds the title string twice (title="(New window) (New window)").
This should fix it.

jenlampton’s picture

Title: Add accessibility for screen reader to external link. » A11y: add screen reader text for external links
jenlampton’s picture

Issue summary: View changes

Updating issue description to be more comprehensive.

douggreen’s picture

StatusFileSize
new8.33 KB
new12.3 KB

The attached patch :

  1. makes the "(new window)" label configurable
  2. compares the title and the "(new window)" label in a case-insensitive manner without the parenthesis. See Drupal.extlink.compareLabels().
  3. combines the two titles in a more readable manner, see Drupal.extlink.combineLabels().

It does not update the tests.

douggreen’s picture

I created a MR, so I'm hiding all of the patches attached to this ticket, to avoid confusion.

douggreen’s picture

There is some overlap (and conflicts) with #3182802: Aria-label for external links span throws errors on Accessibility Arc Toolkit so I copied that commit from MR!18 to MR!16 and resolved the conflicts.

jenlampton’s picture

Status: Needs review » Needs work

Accessibility isn't optional. Why is there an option for "Add "(New window)" in the title of links that should open in new window."? The answer to that checkbox needs to be identical to the answer to "Open external links in a new window or tab." So we don't need both.

Either the links are opened in new windows (AND they have a warning) or they are not (and there is no warning). There is not a use-case for having links open in new windows without a warning. That's not accessible.

douggreen’s picture

While I dislike removing options that other people think are helpful, I agree with @jenlampton that the new option extlink_target_append_new_window should not be an option but just always be true.

I'm a little less clear on whether the other new option extlink_target_append_new_window_label should be configurable or some set text. The fact that extlink_target_label is configurable makes me think that extlink_target_append_new_window_label should also be an option.

Also a little unclear to me is if the new JS I wrote should even exist. If both labels are configurable, and if the defaults are as we currently have them, this JS will never be used. And since the site builder has full control over this, is this new JS a waste of time to run in the browser and maintain in code?

douggreen’s picture

This was made an option because of comments starting in #11 above without any discussion until #51. Also, #51 suggested linking to WCAG somewhere, but that was never done. And IMO that is a better thing to have done than making the accessible feature optional. What should we link to?

jenlampton’s picture

> #51 suggested linking to WCAG somewhere, but that was never done.

We could link to https://www.w3.org/TR/2012/NOTE-WCAG20-TECHS-20120103/G201.html

The text they include in that example is (opens in new window) so I'm tempted to always use that exact text and not allow for it to be modified. The only use-case for modification of the (opens in new window) text would be if someone had already entered the missing warning into the existing link is external text.

Making neither configurable would remove that use-case, but I also dislike the idea of removing options that already in use on production sites. If the link is external text changed suddenly it could cause problems for production sites with translations. (Though I wonder about the use-case for that as well. Was it only so that people could add the missing warning?)

In a perfect world I'd like the screen-reader text to always be the same, either (link is external) for opening links in the same window, or (link is external, opens in new window) for opening links in a new window. That would make the same translations work for everyone, and for a consistent screen-reader experience across sites.

To remove the link is external text override, however, we'd need to write a BC layer that would check for an existing value that's different from the default, and if that existed, use that override instead of the non-configurable text. We could even have the admin UI hide the existing field for the override when it's not already in use.

It's more work, but would make for a better user experience as well as more consistent accessible output.

douggreen’s picture

I like the idea of removing the config option extlink_target_append_new_window_label which defines the label text and is new to this patch, always using the recommended text, and linking to the external resource (from above). This isn't removing an option in production. This is removing an option that someone in this thread thought helpful, and replacing it with a standardized (maybe industry standard) a11y text.

The current patch checks for "new window" in the existing label (not "opens in a new window") so I think that the existing patch is already backwards compatible with production systems.

If we agree, then what's left is to remove the config option extlink_target_append_new_window_label, link to the external resource, and make sure the tests work. If I understand correctly, we're pretty much at the place that you started with this ticket, it just took me a while to get there (sorry). What do you think?

douggreen’s picture

Status: Needs work » Needs review

smustgrave made their first commit to this issue’s fork.

smustgrave’s picture

Version: 8.x-1.x-dev » 2.0.x-dev

Tests are all green and all eslint issues fixed for the pipeline. Thoughts? Would like to include with 2.0.x release.

smustgrave’s picture

Status: Needs review » Fixed

Going to get a little ahead of myself and merge as this is the last one on the radar for a beta1 release.

Status: Fixed » Closed (fixed)

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

penyaskito’s picture