Page MenuHomePhabricator

Create a MW-wide class for screen reader-only content
Open, Needs TriagePublic

Description

IIRC MediaWiki has a mixin visually-hidden that gets some usage across MediaWiki code (such as T209253), but there’s no common way to visually hide the text for screen reader users.

I think we should come up with one common class for this, since, unlike the MediaWiki developers, end-users in Wikimedia projects can’t use a relevant mixin and shouldn’t have to duplicate the code for an extremely common occurrence for accessibility work. This is especially true when considering that end-users can’t even rely on MediaWiki:Common.css for this, since any wiki-level CSS won’t load instantly for users on mobile.

Event Timeline

@stjn: Is this about MediaWiki core? Asking as there is no codebase project tag associated to this task.

Seems like something of an interest for Codex efforts as well, since it could provide an increased use of accessibility text in the projects, which is a net benefit for UI standardisation.

Jack_who_built_the_house renamed this task from Provide a common class for visually hiding the text to Create a MW-wide class for screen reader-only content.Mar 18 2024, 1:53 PM

An established practice to make content visually hidden, screen reader-visible seems to be using CSS like this

.sr-only {
  border: 0; 
  clip: rect(0 0 0 0); 
  height: 1px; 
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
}

A simple example where it can be used:

In the style guide for copy, we see this:

image.png (313×802 px, 22 KB)

The text "Warning!" is redundant for regular users – there is already a yellow box and an icon. But users of screen readers should see it (role="alert" is not quite relevant here, and I'm not sure if aria-live="polite", which OOUI messages use, is).

Volker_E subscribed.

This is already the case and in place since 2015:
https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/refs/heads/master/resources/src/mediawiki.less/mediawiki.mixins.less#179

If you import @mediawiki.mixins.less you can add this mixin to the selector of your need.

Respectfully, @Volker_E, I don’t think you’ve read the task correctly. I know a mixin is a thing, I am saying that the end-users of Wikimedia projects should have access to the same mixin via an agreed class name since that would improve accessibility and re-usability of code across projects. Currently this sort of thing gets copied across wikis on an ad-hoc basis, whereas it would be better to create a centrally managed utility class.

@stijn Thanks, you're right. I've misunderstood just based on the last comments.