Problem/Motivation

The way 'more links' are currently built leads to bad practice in terms of accessibility — links with text like "Read more", "Learn more", etc. provide insufficient information about link purpose to screen reader users. This is especially problematic with lists of items, e.g. a view of blog teasers, leading to numerous links all announced by a screen reader as "Read more" with no additional context.

See Accessible "Read More" Links for a good general overview of the issue.

Proposed resolution

Add an aria-label attribute to the more link, with customizable text and token support — example: "Read more about [node:title]". In most cases, the screen reader will announce the aria-label text instead of the link text (watch a short demo on YouTube to see this in action). This provides the additional context needed for screen reader users, while keeping the link text short for others.

Though this is often accomplished with a "visually-hidden" element within the link text, recent testing indicates that "screen readers consistently and correctly expose aria-label overriding the anchor text on the Windows 10 platform as well as on mobile devices- iOS and Android."

This issue provides an alternative approach to #3115149: ARIA label for More link, which, despite having "aria label" in the title, uses CSS-hidden text coupled with aria-hidden and role=presentation.

User interface changes

Add a "more link aria-label" field and token browser to the formatter settings form.

Screen shot of the settings form with new fields.

API changes

None.

Data model changes

Add 'more_aria_label' to schema.

Issue fork smart_trim-3194955

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:

  • aria-label Comparechanges, plain diff MR !8
  • 8.x-1.x Comparecompare

Comments

justcaldwell created an issue. See original summary.

justcaldwell’s picture

StatusFileSize
new3.2 KB

Initial patch attached. This adds:

  • 'More link aria label' field and token browser link to the settings form.
  • 'more_aria_label' to smart_trim.schema.yml
  • 'aria-label' attribute to more links if the setting is not blank.
  • A dependency on the token module.

If the additional dependency is undesirable, the new elements could be made conditional with a check for token.

justcaldwell’s picture

Status: Active » Needs review
othermachines’s picture

Patch looks good. Tested in Drupal 8.9.13 and smart_trim 1.3.0 (as good as -dev since there are no new commits since last release). A simple yet complete solution. Thanks!

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

markie’s picture

@justcaldwell thank you so much for this patch. I actually used this issue and patch for my global contrib talk tonight. One thing that came up as I was showing it is can we add drupal/token as a requirement in the composer.json and info.yml since we are using token?

justcaldwell’s picture

Hi @markie! Great point, the token dependency should definitely be added to composer.json. I can upload an updated patch a bit later today, if that's the right move. To be honest, I'm not fully up to speed on the new issue fork workflow yet :0

justcaldwell’s picture

StatusFileSize
new3.57 KB

Here's the updated patch. No diff, as I only made the single change to composer.json.

markie’s picture

Hey it's cool.. I'll take care of it, but more and more maintainers are going to start forcing the MR over patches. Also it's an easier workflow since all you should need to do is confirm push access, checkout the merge repo and then edit there and push.. no need to create and upload a patch.

markie’s picture

Issue tags: +GlobalContributionWeekend2021

  • markie committed a341b08 on 8.x-1.x
    Issue #3194955 by markie, justcaldwell: Improve more link accessibility...
markie’s picture

Status: Needs review » Fixed

err.. merge fixes this right?

rachel_norfolk’s picture

Issue tags: -GlobalContributionWeekend2021 +ContributionWeekend2021

Just doing a little tag tidying. Nice work everyone!!

Status: Fixed » Closed (fixed)

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