Introduce external_link_icon helper and replace existing usages of sprite_icon('external-link')
!147028 (merged) introduces support for the aria_label attribute on the sprite_icon helper. This particular MR improved accessibility by applying an aria label to an external-link icon, but there are several other external link icons in the codebase that would benefit from the same treatment.
My suggestion is to create a method in app/helpers/icons_helper.rb (or even app/helpers/external_link_helper.rb) that wraps the external link sprite icon and provides an aria-label as standard. Something like this:
def external_link_icon(**args)
sprite_icon(
'external-link',
args.merge(aria_label: _('(external link)'))
)
end
We can then replace existing usages of sprite_icon('external-link') to benefit screen reader users.
Edited by James Nutt