Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
As seen in the Web Accessibility Tutorials, it is required that <figure>
tags should have a role="group"
attribute.
Steps to reproduce
- Install Drupal with standard profile
- Create a node of type "Basic page"
- Add an image using CKeditor and check the "caption" checkbox
- Save the node
- Ensure that there is no role="group" attribute on the
<figure>
tag
Beta phase evaluation
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
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.
Comment | File | Size | Author |
---|---|---|---|
#11 | role=group-for-figure.png | 40.72 KB | mgifford |
#7 | Caption-button-stick.png | 175.14 KB | mgifford |
#1 | figure_role_group-2509700-1.patch | 13.83 KB | DuaelFr |
Comments
Comment #1
DuaelFrComment #2
DuaelFrComment #3
DuaelFrComment #4
mgiffordI'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:
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.
Comment #5
DuaelFrI 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:
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 ;)
Comment #6
mgiffordOk, 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.
Comment #7
mgiffordThis 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.
Comment #8
DuaelFrThe manual testing of this issue is blocked by #2533738: Image align radio and caption checkbox in CKeditor does not work anymore
Comment #9
mgiffordIt's now being worked on #2540850: (regression) EditorImageDialog alignment & captioning are not working so hopefully this gets fixed soon.
Comment #11
mgiffordLooks 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.
Comment #13
DuaelFrThat fail seems to come from the branch, not from the patch.
I'd retest tomorrow to see if it's better...
Comment #15
DuaelFrTestbot is happy again :)
Thanks Mike, I totally forgot to come back this morning.
Comment #18
DuaelFrTests are quite unstable these days...
Comment #19
webchickCommitted and pushed to 8.0.x. Thanks!
Comment #22
jigariusOnce 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.
Comment #23
joakland CreditAttribution: joakland commented#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.
Comment #24
Drupal Duppy CreditAttribution: Drupal Duppy commentedHas anyone made any progress on the point that #22 & #23 bring up? Some accessibility checkers flag this as an error, Siteimprove for example.
Comment #25
CarlyGerardI 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.
Comment #26
mepperly CreditAttribution: mepperly commentedAny 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.
Comment #27
CarlyGerard@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...