Problem/Motivation
There are 2 issues with the Font Awesome option:
1. CSS: dot missing, was probably meant to be .extlink i
2. Markup: Accessibility issue.
An aria-label on <i> is not valid with AXE for example: https://jsfiddle.net/8wvby7pt/.
Same on <span> it seems: https://jsfiddle.net/8wvby7pt/1/
PS: It seems this was changed from span-i to span-span in #2467383-35: Accessibility Enhancements.
Proposed resolution
1. Update the CSS to .extlink i
2. And the markup to use FA's sr-only class + use aria-hidden="true" on the icon:
<span class="fa-ext extlink">
<i class="fa fa-external-link" aria-hidden="true"></i>
<span class="sr-only">(link is external)</span>
</span>
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | fontawesome_fixes-3378557-9.patch | 2.31 KB | herved |
Issue fork extlink-3378557
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:
- 3378557-2x
changes, plain diff MR !45
- 3378557-fix-font-awesome
changes, plain diff MR !13
Comments
Comment #2
herved commentedComment #3
herved commentedComment #4
herved commentedEdit: ignore this, it only contains the CSS fix but there is also a problem with the markup (see updated IS).
Comment #5
herved commentedComment #6
herved commentedComment #7
herved commentedHere is the patch with both CSS and markup fixes.
AXE has no issues with that: https://jsfiddle.net/s23w8q4j/
Comment #8
herved commentedComment #9
herved commentedFixing tests...
Comment #10
jbaum_13 commentedThis patch #9 worked for me! Thank you so much!
Comment #11
baysaa commentedIs `sr-only` a native Drupal CSS class? I don't know so asking. I think traditionally `visually-hidden` may be the more appropriate class to use here. So I'd take the patch in the related issue over this one.
Comment #12
herved commentedHello @Baysaa,
sr-onlyis a fontawesome-specific class, added since version 4.6.0 (commit)I'm not a maintainer but I'm not against changing it to
visually-hiddenwhich would make it independent from any FA version.Feel free to post a patch.
Comment #13
clarksl@gmail.com commentedPath #9 worked for me as well. Thanks!
Comment #14
anybodyThanks, could this please be turned into a MR for further review and merge?
Comment #16
herved commentedHi @Anybody, sure, done.
Comment #17
baysaa commented@herved if the icon's using FA then it makes sense that sr-only should also work, thanks!
Comment #18
smustgrave commentedComment #19
smustgrave commentedThink visually hidden would be better as even though we have font awesome icons the library might not be present (so the checkbox setting is unchecked) so not sure sr-only would cover all cases.
Comment #23
smustgrave commentedComment #24
cboyden commentedI'm testing the latest dev of the 2.0.x branch, including this commit, and it's still outputting aria-label inappropriately.
To reproduce:
First, the aria-label attribute is being output on a nested span tag. The attribute isn't intended for use on elements with a generic role, including the HTML div and span tags. Most assistive technologies will ignore aria-label on generic tags.
Second, the aria-hidden attribute doesn't need to be added if the value is "false." See aria-hidden where the Note says "At the time of this writing, aria-hidden="false" is known to work inconsistently in browsers. As future implementations improve, use caution and test thoroughly before relying on this approach." In the proposed draft for ARIA 1.3, the "false" value is supposed to be handled the same as if it's undefined (i.e. attribute is not present).
Third, the span containing the FA icon markup has a role of "img" and is not hidden from assistive technology, which means it should have something in the way of alt text, but the markup inside that span doesn't contain any text.
Comment #25
herved commentedIndeed this doesn't seem valid: https://jsfiddle.net/cafsjowu/1/
It looks like #3172378: Prevent extlink icons from breaking into new lines recently committed added an extra span wrapper in the mean time?
Can you please create a new issue @cboyden? thanksPS: The added code there looks convoluted. I wonder, wouldn't simply work?Edit: Ok, we can fix it here I hope.
Comment #26
smustgrave commentedI'll revert this when I'm back in front of my computer.
Comment #27
smustgrave commentedReverted
Comment #29
smustgrave commentedSo what exactly is needed for this one? 1 of 2 bugs left open.
Comment #30
smustgrave commentedDoes https://www.drupal.org/project/extlink/issues/3492645 fix the issue here?
Comment #31
smustgrave commentedSince there's been no follow up