openlibhums / hourglass

Hourglass press theme for OLH
GNU Affero General Public License v3.0
1 stars 1 forks source link

Create accessible external links #306

Open joemull opened 6 months ago

joemull commented 6 months ago

User stories

Proposed solution Use JS to detect links to external domains and add attributes as follows:

<a
  href="https://external.example.org"
  rel="noopener"
  target="_blank">Example
  External Resource<span class="sr-only"> 
(opens in new tab)</span></a>

Also, potentially add a visual cue.

This solution would satisfy WCAG 2.2.

Context

dev notes Using an icon to indicate a link opens in a new tab or window (CSS rule that checks target) e.g. a[target="_blank"]:after

@joemull will investigate how this affects TinyMCE and how we can ensure user provided links get this accessibility improvements

StephDriver commented 5 months ago

I have reached a similar conclusion - for external links, we should indicate in the text that the link will be opening in a new tab. And I prefer the solution with a visual cue Something along these lines:

image

as described on Digital A11y

Perhaps the example that combines the aria-describedby and the visual cue? while adding "opens in a new tab" does satisfy the WCAG, it does add more cognitive load than a visual cue.

StephDriver commented 2 months ago

I wonder whether it would be cleaner to do this just in the CSS without needing any JS, with a target for any links which have other domains?

a[href^="http"]:after