Problem/Motivation
Over in #2962110-39: Add the Media Library module to Drupal core, we discovered that there is an accessibility problem with the entity operation drop-buttons exposed by Views. Namely:
The entity operations (dropbutton) links are [a] problem ... users need to know which media item they apply to. Just like bulk-ops checkbox, the dropbuttons currently get context from the HTML table row structure. But in the new grid, the dropbutton is outside of the rendered entity's <article> wrapper.
There's already an issue to address this in EntityListBuilder, but the dropbuttons in the new media library actually come from the EntityOperations views field plugin.
Proposed resolution
Change the EntityOperations plugin so that the label of the entity is embedded in a way that will be visible to assistive technology.
Remaining tasks
Write a patch, write tests, get the accessibility team's blessing, and commit.
User interface changes
Entity operation drop buttons in views may change when seen by screen readers, etc. A Views plugin may receive new administrative UI options.
API changes
None - there is markup change.
Data model changes
None anticipated.
| Comment | File | Size | Author |
|---|---|---|---|
| #56 | 2973124-nr-bot.txt | 149 bytes | needs-review-queue-bot |
| #48 | interdiff_45-48.txt | 676 bytes | vsujeetkumar |
| #48 | 2973124_48.patch | 27.2 KB | vsujeetkumar |
| #46 | interdiff_43-45.txt | 945 bytes | vsujeetkumar |
| #45 | 2973124_45.patch | 26.41 KB | vsujeetkumar |
Issue fork drupal-2973124
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:
Comments
Comment #2
andrewmacpherson commentedWe already have #2960828: Link labels generated by the Entity List Builder should provide more context for a11y to address the drop buttons from EntityListBuilder, which will be a more predictable situation to compute names for.
Comment #3
phenaproximaThis issue blocks the new Media Library (added in #2962110: Add the Media Library module to Drupal core) from being stable, according to this excerpt from Slack:
Comment #4
andrewmacpherson commented@phenaproxima:
Yes, that's correct. The table row context I mentioned refers to "programmatically determined link context" in WCAG. Most screen readers provide tools for dealing with tables, like quickly jumping to the start/end of a row. But you can ask a screen reader to announce the headers for the current table cell, on demand, and you don't need to move away from the link. In the absence of explicit row-level headers, some screen readers will treat the first cell in the row as a header. I think it's wise to assume these tools are power-user level; not all screen reader users will be used to them.
Screen readers also have tools for listing links, or listing buttons. In this case, you don't have the benefit of the table row context. This issue can help screen reader users here.
We also have issues to make row-level headers too - #2962585: Treat entity label as a row-level header in entity list tables and #2770835: Add support for tables with two headers in views table display.
Comment #6
rodrigoaguileraFollowing the same strategy as #2960828: Link labels generated by the Entity List Builder should provide more context for a11y adding a visually hidden text with the label of the entity.
Comment #8
wim leersThis looks great!
Now we just need some test expectations to be updated, then it'll pass tests again :)
Comment #9
rodrigoaguileraI'll work on this
Comment #10
chr.fritschLet's try to fix the tests
Comment #11
rodrigoaguileraI reached a similar point fixing the tests so I think this is good to go.
Comment #12
wim leers@chr.fritsch said he'd like to see this be more elegant. I did some digging.
I found https://stackoverflow.com/questions/16241197/xpath-to-retrieve-text-with..., which led to me trying the expression
string-join(//span[@class="inner-span"]/text())on their example, and that returnsWhich is pretty much what we want to use here.
Hope this helps!
Comment #13
andrewmacpherson commentedThe links will need to satisfy the new "Label in name" success criterion from WCAG 2.1. The short explanation is: don't put any visually-hidden text in between visible words in the link/button name. (So "Manage [Basic page] fields" would fail, for example.)
In this case, it's easy to satisfy WCAG because we only have single-word links to begin with. The changes to EntityListBuilder in patch #10 satisfy WCAG "Label in name" (for English, anyway - translators could cause a WCAG problem, so we'll need to provide guidance on this in the d.o translation handbook, say.). There's a plan to carry out an audit for WCAG "Label in name" across the whole of core, so we'll get another chance to confirm this anyway.
Comment #14
andrewmacpherson commentedtitle tweak, a bit clearer about what the improvement is.
Comment #15
alexpottI think we need a change record here. It is highly likely that some contrib / custom tests are going to fail because of this sensible change so I think it is worth having so when that happens there's one to point at.
Comment #16
andrewmacpherson commentedwriting a change record now...
Comment #17
andrewmacpherson commentedI didn't write a change record, it stlll needs work. Here's a new patch which updates some of the remaining entity operations, in classes which extend
EntityListBuilder.After looking again at #2960828: Link labels generated by the Entity List Builder should provide more context for a11y, I don't think we need both issues, we can do it all in one issue. Some things to consider:
The approach taken by the patch at #2960828-6: Link labels generated by the Entity List Builder should provide more context for a11y is to change the link title in
EntityListBuilder::buildOperations(). It uses the operation title as visible text, followed by the entity label, then entity bundle label, in the visually-hidden span. This seems to work generically, but has a few issues. I use [square brackets] for the visually-hidden part:EntityListBuilder::getDefaultOperations().For example MenuListBuilder changes the "Edit" operation title to "Edit menu". There could be some more unusual sentences resulting from this. An example is "Edit menu [User account menu menu]"The approach in my patch here adds visually-hidden context to all the individual operations that are added by classes which extend
EntityListBuilder::getDefaultOperations(), when they add their own operations. There are some issues here too:This patch adds context to operations in the following classes:
I stopped updating them after I had seen a few. I figured I would report back here, to get feedback about this! So what do people think about the approaches from these two issues? So far it's only considering how the core English versions are phrased.
TODO - the following classes still need visually-hidden link context added in their own
getDefaultOperations()methods:Comment #18
andrewmacpherson commentedOops, forgot to attach my patch...
Comment #20
phenaproximaDidn't change any tests (so we can see what this breaks, and then fix it all), but added some context wording to the rest of the list builders mentioned in #18.
One thing I would suggest is that we might want to add a helper method to the base list builder class to do this. That will give us more freedom to improve the internationalization of this approach. However, speaking a near-total n00b to the world of accessibility, I think the approach taken in #18 makes a lot of sense.
Comment #21
alexpottI have a concern about this. Build sentences from already translated labels often breaks. For example if the label is
What should you do about a problem called potatoesthen this will readEnable What should you do about a problem called potatoes. It looks like we have a couple of problems here. One is capitalisation ieEnable Whatthe other is it possible to imagine things that very confusing. Say the title isEnable people to learn moreand then you'll haveEnable Enable people to learn moreComment #23
rodrigoaguileraIs quoting a good practice here like
Enable "Enable people to learn more"?Comment #24
alexpottWe've done that for things like
and
So yeah I think that that is way forward.
Comment #25
rodrigoaguileraI attach a patch that changes all the operations to have the label between quotes and fixes the tests (hopefully).
Comment #27
andrewmacpherson commentedRe #25 - thanks for the updated patch rodrigoaguilera. I'm travelling today so I don't have time to review it in detail.
Re #23 and #24...
The quotes idea is probably good for visible text. Likewise, other punctuation like dashes or colons could help. Italics are another method which can work visually.
But for text in a visually-hidden span, there is very little benefit to using common puntuation to indicate the entity label. Screen readers don't announce it, or give any special indication, for the most part. Some screen readers do offer user preferences to control the announcement of punctuation, but the default settings are generally silence for common punctuation. The upshot is that we can't expect screen reader users to notice quote marks.
The thing that makes this tricky, is that we have no control over the phrasing in entity labels created by users - but these are the contextual information we want to convey in this issue.
The latest patches here have phrasing for the particular entity lists, but there will always be clumsy sentences this way.
So the important question is whether:
Comment #28
rodrigoaguileraCan you provide an example about tailoring the the operation names. Is not very clear to me.
Attached is another attemp at fixing the tests.
Comment #30
wim leersI'm also not sure what that is asking exactly.
Comment #31
rodrigoaguileraHere is the proper patch. The interdiff is the same
Comment #34
wim leersThe link Set "?!`U>&`A" as default was not found on the page.This seems like an encoding issue.
Let’s use a random string that does not contain ampersands and other characters that are HTML-encoded. That will likely fix this.
(Typing on the subway, unable to actually test this.)
Comment #35
rodrigoaguileraIs not encoding, is a consistent fail because we are introducing HTML in the middle of the sentence that will be stripped by xpath text() method.
I changed the clickLink() for an xpath that searches for the two text objects that exist in that element in the right order. I can't think of a way of passing those throgh t().
Maybe in this case is better to create an xpath that translates to "click on the third link of the dropdown ul". What do you think?
I definitely learned a lot of xpath this sprint week :)
Comment #36
rodrigoaguileraComment #37
rodrigoaguileraugh, bad patch again. Now I am ignoring that folder
Comment #38
phenaproximaPersonally, I favor pragmatism here. Internationalization issues are extraordinarily tricky, and I'm not sure what mechanism we could use to tailor the operation names. I think if we try to solve it that way in this issue, we might be here for literally years.
So IMHO, although it's sub-optimal, we should go for the most accessible short-term solution and take a generic approach. But it might be worth opening bigger conversations in other issues about how we might solve the difficult problem of true internationalization for entity operations. That's way beyond my pay grade, so I can't say I have any clue how that would proceed, but it seems like we can make a worthwhile and positive short-term gain here, so I'd favor that.
Comment #40
joachim commentedI don't think we need to add this.
The 'delete' operation will have been added by the grandparent class EntityListBuilder, and we set the context there.
Comment #43
vsujeetkumar commentedRe-roll patch created for 9.1.x, Please review.
Comment #45
vsujeetkumar commentedFixed more test, Please review.
Comment #46
vsujeetkumar commentedPlease ignore the above interdiff, check this.
Comment #48
vsujeetkumar commentedFixed the test, Please check and advise it is up to the mark or not.
Comment #56
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #57
mgiffordTagging for https://www.w3.org/WAI/WCAG21/Understanding/label-in-name.html