Needs work
Project:
Drupal core
Version:
main
Component:
media system
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
16 Sep 2019 at 11:59 UTC
Updated:
19 Jun 2023 at 18:46 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
xjmPromoting to major bug as per #2834729-200: [META] Roadmap to stabilize Media Library.
Comment #3
bnjmnmThere is already an announcement for "Save and Insert" - this is what is read by Voiceover after inserting media with that button (with the announcement in bold). The button that opened the add media dialog is focused, then:
Of course it can be changed to something different if "Added one media item/Added media items." is not sufficient.
In this patch, I added a similar
AnnounceCommandto\Drupal\media_library\Form\AddFormBase::updateLibrary(). The results are very different in Chrome and Safari (the announcement is in bold)Chrome:
*The announcement is never read, but is present in the
drupal-live-announcediv. The behavior is the same whetheraria-liveit set to polite or assertive*Safari:
Aside from needing to find a way to get Chrome to acknowledge the announcement, I'm also wondering if the other Chrome/Safari differences are acceptable (particularly since Safari will just read through what is potentially a very long form). If this difference is a problem, it may inform how the Chrome issue is addressed.
Note: One approach already attempted for the missing announcement in Chrome: using a dialog event listener. This did not work as "Save and Select" does not generate a new dialog - it uses an AJAX replace instead.
Comment #4
seanbI believe you are right that the 'Save and insert' button should already work as expected. So I think we can remove this from the IS.
Regarding the 'Save and select' button, there are 2 things that happen:
aria-liveregion with the number of selected items.I've seen in multiple occasions that changing the focus to an area with a lot of content results in the
aria-livecontent not being announced properly. Not sure if there is a way to fix that? Maybe setting the focus to a logical place with less content helps? Also see #3081523: Improve the focus behaviour after clicking 'Save and select' in the media library. to fix the focus.Apart from that, by default we only announce the number of selected items, we do not announce the fact that the media items have been saved. Maybe we could add a success message to the page for that? This would also generate content that would be announced to the user and provide visual confirmation that the item is saved as well. Not sure if that is a different issue or not.
Just some thoughts.
Comment #5
bnjmnmThanks @seanB! based on your feedback I added the patch from #3081523: Improve the focus behaviour after clicking 'Save and select' in the media library.. It addresses most of the discrepancy between Chrome and Safari's announcements. Unfortunately, the announcement is still missing from Chrome, but the fact that the announcements are no longer VERY different makes this much easier to deal with. Perhaps the success message will help with that.
Comment #6
rainbreaw commentedI just ran through this with VoiceOver on Chrome and Safari using the patch in comment #3.
While it would be great to get Chrome working correctly with VoiceOver, it is commonly known that VoiceOver is designed to work with Safari and there will be differences. As long as the differences are usable, it isn't a blocker to have them be different.
I think the newest patch solves the issues that are raised by this ticket.
Chrome:
When going through in Chrome, after adding items I am told how many items I've added, and it is understandable.
Safari:
When using Safari, I can tell how many media items I've added, and how many more I can add. This is very nice. While it would be great to have this second piece in Chrome, it is not a blocker.
I'm going to flag this for @cboyden's team to test with Jaws and NVDA during their assistive tech walkthrough on Thursday, as well.
------
I'm curious about the protocol for creating tickets for new items that I found while doing this? I don't want to mess with the current flow, so looking for the right way to do this. Here is what I found for the record (which I'll branch off with feedback):
Comment #7
bnjmnmThanks @rainbreaw, this helps move things forward.
Regarding the filing of new issues, by all means create new ones when you run into problems that haven't been reported. It's very appreciated and not at all disruptive. Very glad you're noticing these things.
A few things to keep in mind when you create the issues
Comment #8
seanbFor point 1 in #6 we already have #3035331: Improve keyboard focus behaviour of vertical tabs in MediaLibraryWidget. I don't think we have issues for the other 2 points, so if you think we need those please feel free to create them :)
Thanks for helping us test and improve!
Comment #9
bnjmnmUpdated the patch to deal with multiple additions and added the patch from #3081523: Improve the focus behaviour after clicking 'Save and select' in the media library. so the screenreader doesn't choke on a large element and should help with the upcoming assistive tech walkthrough.
I also tried a few different approaches to see if I could get Chrome to cooperate with voiceover, but they were unsuccessful. It sounds like this may be acceptable, but if the conclusions of the walkthrough determines something different there are other options to investigate.
Comment #10
seanbI'm wondering if we should use the messenger service to add a success message instead of an announcement? The messages also have an announcement (by default a part of messages if I'm not mistaken) and will provide extra visual confirmation.
Comment #11
bnjmnmRe #10
This is a good suggestion - and the outcome in this patch is bittersweet.
I created an AJAX Command (with test coverage) for the JavaScript Drupal.Message() functionality, so the message could appear in the dialog. This will be useful to Media Library and core in general. However, I also discovered that the announcement will not make it through (at least with Voiceover, regardless of browser) if the priority isn't set to assertive.This can't be done with message without changing the message type, so AnnounceCommand still needs to be there. A message has still been added to the experience, though.
[Edited to clarify: this is not an issue with the AJAX Command, which works fine with screenreaders overall. Rather, this is an issue specific to how Voiceover (and perhaps other screenreaders -- they have not been tested) behaves after the Media Library Widget form is rebuilt after uploading media. I had this same issue when I was using AnnounceCommand with default priority]
If it turns out other screenreaders do not need the "assertive" priority to be announced, then this potentially means the announcement being read twice. If this is the case, the Message portion of this will need to be discarded, but the MessageCommand should still probably be added in a separate issue.
Comment #12
seanbThat message command also looks very useful for #3059955: It is possible to overflow the number of items allowed in Media Library. I like it, nice work!
Hopefully we can figure out how to get assistive tech to announce it properly.
Comment #13
phenaproximaI asked @bnjmnm what this needs in order to land; he says it could use general accessibility review, especially confirmation (or denial) that non-VoiceOver screen readers don't announce the message multiple times.
Comment #14
wim leersHaha I unwittingly implemented a simpler (and probably hence inadequate) variant of this too in #3034242-8: Hide "Save and insert" and "Additional selected media" from users by default, see #3034242-9: Hide "Save and insert" and "Additional selected media" from users by default point 4.
Comment #15
oknateI added a more generic issue for the new ajax command: #3086096: Add a generic Ajax Message command
We need this for this issue too: #3059955: It is possible to overflow the number of items allowed in Media Library
Comment #16
wim leersComment #17
wim leersFor #15 + #16.
Comment #18
oknateRerolling on top of #3086096-20: Add a generic Ajax Message command
Comment #19
rainbreaw commentedI've tested this with VoiceOver on MacOSX, with both Chrome and Safari, no eyes, no mouse, and the announcement works well.
Noting here that it looks like #3059955: It is possible to overflow the number of items allowed in Media Library may be moot now, as when testing this it no longer allowed me to add more than the allotted number of items with the screenreader/tab key (though I haven't tested this yet).
Is there something else that needs to be reviewed here, or can this be moved to RTBC?
Comment #20
phenaproximaThanks @rainbreaw! I think we can move this to RTBC once #3086096: Add a generic Ajax Message command is in, just by reposting the do-not-test patch from #18. Removing the "needs accessibility review" tag.
Comment #21
wim leersYep, once #3086096: Add a generic Ajax Message command lands this is ready :)
Crediting @rainbreaw for accessibility reviews, @seanB for code reviews, myself for code review (duplicate implementation in another issue), @phenaproxima for coordinating.
Comment #22
phenaproximaUncrediting myself; thank you for the kind thought, but my work did not help shape this patch. :)
Comment #23
wim leersReuploading the patch from #18 now that #3086096: Add a generic Ajax Message command landed 🥳
Comment #24
alexpottI think there ways of getting entity labels - see \Drupal\Core\Entity\EntityTypeInterface::getCountLabel(). But not entirely sure of how it should be used. I think this means you can do
$this->t('Added @label.', ['label' => $entity_type->getCountLabel(count($media_ids))]);It would be great to have some test coverage of the message appearing etc...
Comment #25
oknateAssigning to myself to work on test coverage.
Comment #26
andrewmacpherson commentedThis sounds suspicious. The new MessageCommand employs
Drupal.Message()in the browser, which in turn usesDrupal.announce(). Can't the assertive priority be passed via MessageCommand?I see that there is an
InvokeCommandfor focus, which precedes theMessageCommandandAnnounceCommandin this PHP code. Does the client-side AJAX library process the commands in this order? I'm wondering if this could be a timing issue, rather than the difference between polite and assertive live regions. A focus change is far more important than a polite announcement; so if an polite announcement was made withDrupal.announce(), and then a focus change happens afterwards, then assistive tech could be justified in ignoring (or aborting) a polite announcement. OTOH if a change was made in a polite live region after the focus change, then AT could just defer it until after the name/role/value of the focused control was announced.aria-live="assertive"has flaky support across browsers and AT. Using assertive instead of polite can make no difference at all in some browers/AT combinations. So it's not be a reliable way to make sure information is conveyed here. My knowledge about this is sketchy and a couple of years out of date, mind you.Comment #13 hasn't been addressed. Has manual testing been done with any browser and screen reader combinations on Windows? I only see VoiceOver + Chrome/Safari mentioned here. I'm less concerned about repeat announcements, than whether the announcement is made at all. Particularly since this is the first time we're using this pattern with MessageCommand.
Speculation: a polite/assertive live region might be following some user preferences for verbosity and/or delay. For example, VoiceOver (on macOS) has a setting to control the delay before announcing descriptions. A support request we commonly hear in the a11y community comes from developers want to know why their
aria-describedbyisn't working. It turns out it does work, but they were tabbing to another control quicker than the delay setting. Now I'm wondering if any screen readers have implemented verbosity/delay settings for aria-live announcements; AFAIK they don't, but maybe that's changed.Comment #27
oknateAddressing #24
1. ✅ Nice catch, updated.
2. ✅ Added test coverage.
Additional changes:
Renaming the selector based on #3059955-22: It is possible to overflow the number of items allowed in Media Library and work done after that, so that the selector matches that patch.
After working on the MessageCommand, I was pretty sure we don't need the extra AnnounceCommand, so I tested it out and you can set it assertive from the new MessageCommand like this:
It will reach Drupal.Announce with the correct priority. I see that Andrew picked up on this as well in #26.
I updated the change record to explain how this is done: https://www.drupal.org/node/3086403
I intentionally left the code coverage here light, because #3055648: Frequent random fail in \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTest is RTBC which totally refactors this test. Once that is in, we can add the announce assertion to this method:
If the $operation is "select", we can assert the announcement happens within that method.
So to keep the changes light for the inevitable refactor, I'm only adding light test coverage for now.
I copied over
::assertAnnounceContains()from MessageCommandTest(). I had copied it into MessageCommandTest(). So I think it's time to create a test trait for this: #3087213: Create a test trait for assertAnnounceContains and assertAnnounceNotContainsComment #28
oknateRemoving unused use statement.
Comment #29
oknateReroll after this issue committed: #3055648: Frequent random fail in \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTest
Comment #31
wim leersManually tested with Voice Over + Safari. Immediately after triggering "Save and select" this indeed announced 🥳
Was going to RTBC, but then figured @andrewmacpherson would probably want to do so himself.
Comment #32
phenaproximaTagging this to be worked on at DrupalCon Amsterdam.
Comment #34
chaithanya.m commentedWorked 3081526-23.patch for me. After clicking the 'Save and select' buttons of the add form, the outcome is announced on applying the patch. See the screenshot announcement.png
Comment #35
quietone commented@chaithanya.m, thank you for confirming that the patch in #23 worked.
The patch in #29 no longer applies. This will need a reroll, setting to NW for that. Also to do is the accessibility review and the issue summary is out of date as well.
Comment #36
Vidushi Mehta commentedPatch rerolled.
Comment #37
phenaproximaComment #38
samiullah commented#36 looks good. Needs code review before moving to RTBC
Comment #40
abhijith s commentedApplied patch #36 on 9.2.x and it works fine.Now the notice is showing,Adding screenshot after applying this patch.
Comment #41
volkswagenchickAdding
NorthAmerica2021andEasy Out of the Boxtags for visbility.DrupalCon NA is April 12-16 with a focus on EOOTB on Wednesday, April 14.
Thanks
Comment #45
nishantghetiya commentedReroll patch for 9.3.x. Attaching a screenshot.
Comment #46
chetanbharambe commentedComment #47
chetanbharambe commentedVerified and tested patch #45.
Patch applied successfully and looks good to me.
Testing Steps:
# Goto: Extend
# Install Media Library module
# Goto: node/add/article
# Select Full HTML from text format
# click on the "Insert from media library" icon
# Choose the image
# User is not able to see "Added 1 media item" message once adding the image.
Expected Results:
# User should see the "Added 1 media item" message once adding the image.
Actual Results:
# User is not able to see the "Added 1 media item" message once adding the image.
Looks good to me.
Can be a move to RTBC.
Comment #48
phenaproximaThanks for testing this! I think we still need it to be manually tested with a screen reader and signed off by a member of the accessibility team, though, since this is primarily an accessibility issue. Also, I'm wondering if we still need to display a visible message, since there is an AnnounceCommand in core.
I'll see if I can get a member of the accessibility team to review this.
Comment #49
rinku jacob 13 commentedi am getting error while applying rerolled-3081526-36.patch for drupal 9.3.x-dev.Adding screen shot for the reference
Comment #52
sonam.chaturvedi commentedPatch 'MR !764 mergeable' applied successfully on 9.5.x-dev.
Test Results:
1. Announcement "Added 1 media item" is visible on adding the image.
2. Tried with VoiceOver, it is able to read the announcement once image is added. However, prefer review by accessibility team.
After patch:

RTBC +1
Comment #54
kristen polTriaging for bugsmash so tagging. I'm not sure what needs to updated in the issue summary per #35.
Comment #57
smustgrave commentedOpened a new MR for D10
Comment #58
mgiffordAdding WCAG 3.1.1.
Comment #59
smustgrave commentedStill needs an accessibility review
Also the issue summary update was requested in #35 and can't tell if that's happened.
Comment #61
mgiffordWoops. 3.3.1
https://www.w3.org/WAI/WCAG21/Understanding/error-identification.html
Comment #62
mgiffordSo close, but... It should be 3.3.1 - sorry folks.
https://www.w3.org/WAI/WCAG21/Understanding/error-identification.html