Problem/Motivation

As seen in the Web Accessibility Tutorials, it is required that <figure> tags should have a role="group" attribute.

Steps to reproduce

  1. Install Drupal with standard profile
  2. Create a node of type "Basic page"
  3. Add an image using CKeditor and check the "caption" checkbox
  4. Save the node
  5. Ensure that there is no role="group" attribute on the <figure> tag

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Feature because it is something new
Issue priority Normal because it only affects screen readers
Unfrozen changes Unfrozen because it only changes markup in a non disruptive way.
Prioritized changes The main goal of this issue is accessibility as this attribute is used by screen readers.
Disruption This change is not disruptive at all as it only concerns a few templates and the role attribute has no visible effect.

Proposed resolution

Add role="group" in the figure markup templates.

Remaining tasks

Contributor tasks needed
Task Novice task? Contributor instructions Complete?
Create a patch Instructions Done
Manually test the patch Novice Instructions
Add steps to reproduce the issue Novice Instructions Done
Embed before and after screenshots in the issue summary Novice Instructions
Review patch to ensure that it fixes the issue, stays within scope, is properly documented, and follows coding standards Instructions

User interface changes

Nothing visible.

API changes

None.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DuaelFr’s picture

Assigned: DuaelFr » Unassigned
Issue summary: View changes
Status: Active » Needs review
FileSize
13.83 KB
DuaelFr’s picture

Issue summary: View changes
DuaelFr’s picture

Issue tags: +Accessibility
mgifford’s picture

Issue tags: -a11y +aria

I'm not sure about this. This is for Groups of Images. I don't think we have a way to display "Multiple images conveying a single piece of information" in Core. We can create figures & captions, but in general you don't use ARIA if the HTML5 already conveys the semantic meaning.

The example that you provided is about a different use case than we can satisfy in Core. Now, in a contributed module (such as a gallery) then this probably would be useful. Collections are sometimes intended to be viewed as groups with a single meaning.

Pulling from the example. We can only do this:

	<figure role="group" aria-labelledby="fig11">
		<img src="castle-etching.jpg"
			alt="The castle has one tower, and a tall wall around it.">
		<figcaption id="fig11">Charcoal on  wood. Anonymous, circa 1423.</figcaption>
	</figure>

In which case because we can't semantically group the set of figures (as they have done in the example) it isn't appropriate to use role="group"

We can mark this for consideration in D9 when hopefully we get this type of functionality through FAPI to control images.

DuaelFr’s picture

I was thinking like you at the beginning but while reading about that I found out that a lot of old screen readers (and browsers) that still not understand the <figure> element would be helped by the aria role.

If you look at the example, each individual figure has a role attribute. More, in the complex images tutorial (which I'd have linked first), the thing is clearly explained:

The HTML5 <figure> and <figcaption> elements can be used to group image and link semantically. Adding role="group" to the figure maintains backwards compatibility with web browsers that don’t support the native semantics of the <figure> element.

I really think that change is minor from a code point of view but it can greatly improve accessibility for people with old screen readers (some of them are really expensive to update). As a bonus, that's going to be part of the RGAA 3.0 requirements (French government accessibility rules that should apply - in the best of the worlds - to all the websites in the country) so having it in Core could be a competitive advantage ;)

mgifford’s picture

Ok, that makes sense.. It would be great to be part of RGAA for sure.

I just went to test it though. Figured the easiest way to test it would be in the WYSIWYG as there's a nice caption checkbox which should allow me to just upload an image, enter an alt text and put in a caption.

Sadly the caption wasn't sticking. I'm not sure if this is related to the patch or a new issue but thought I'd check with you for the best way to test this.

mgifford’s picture

Issue tags: +Needs issue summary update
FileSize
175.14 KB

This isn't a problem introduced with the patch. It's still an issue that's difficult to test at the moment.

Clear documentation on how to test this would be great.

I uploaded the caption button from CKEditor.

DuaelFr’s picture

mgifford’s picture

mgifford’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
FileSize
40.72 KB

Looks good to me. I've done the manual testing to demonstrate the role="group" has been added to the <figure>

I'm just running the bots against it again just to make sure, but am happy to mark this RTBC.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 1: figure_role_group-2509700-1.patch, failed testing.

DuaelFr’s picture

That fail seems to come from the branch, not from the patch.
I'd retest tomorrow to see if it's better...

DuaelFr’s picture

Status: Needs work » Reviewed & tested by the community

Testbot is happy again :)
Thanks Mike, I totally forgot to come back this morning.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 1: figure_role_group-2509700-1.patch, failed testing.

DuaelFr’s picture

Status: Needs work » Reviewed & tested by the community

Tests are quite unstable these days...

webchick’s picture

Category: Feature request » Task
Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.0.x. Thanks!

  • webchick committed 1c5205f on 8.0.x
    Issue #2509700 by DuaelFr, mgifford: Add role="group" to <figure> to...

Status: Fixed » Closed (fixed)

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

jigarius’s picture

Once we add role="group", I think we're also expected to have an aria-label or aria-labelledby to add a label to the element.

joakland’s picture

#22 is correct. To meet WCAG accessibility standards, elements with role="group" need to have an aria-labelledby attribute with a value that matches the id of the figcaption element in the case of a caption, or an aria-label attribute if there is no caption.

Drupal Duppy’s picture

Has anyone made any progress on the point that #22 & #23 bring up? Some accessibility checkers flag this as an error, Siteimprove for example.

CarlyGerard’s picture

I am also interested in figuring out how an accessible label should be added to a media element, if it's going to include role="group." Ideally it would be aria-labelledby, but what will that reference--the figcaption, or a heading? Maybe it's just an aria-label someone can add when uploading media?

It doesn't seem like template overrides allow access to title or configuration label variables, so currently accessible naming is a bit tough.

mepperly’s picture

Any progress or home-brewed patches for the issue brought up by #22? We have on our captioned images, but no aria-label and Site Improve hates this and is penalizing us for every captioned image on the site. As a research-oriented site with lots of in-line images, this is...not good.

CarlyGerard’s picture

@mepperly I created a child ticket for this issue, since the issue is no longer specifically about adding a role, but now about adding a name to that role: <figure> elements with a role of group need an accessible label.

The only thing I did this without realizing that there's potential to remove the role="group" by default from in the first place (that issue is linked in the child ticket). Interested to see the take on that...