Closed (fixed)
Project:
Drupal core
Version:
8.7.x-dev
Component:
media system
Priority:
Major
Category:
Task
Assigned:
Reporter:
Created:
24 Feb 2019 at 00:27 UTC
Updated:
13 Nov 2019 at 05:01 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
seanbHere is a first patch.
1. Changed the media library open element from a link to a button. To do that, I found some issues with the way the library state was used and passed, so had to fix that too (pretty happy about this).
2. Changed the title of the media library for clarity.
3. Added progress messages to AJAX buttons in the widget so the widget AJAX action can benefit from #2973140: Convey AJAX progress messages to assistive technology. when it lands.
4. Added announcement when the widget selection is updated.
5. The open button is currently still removed when the maximum number of items reached. I tried having a disabled button, but these don't allow focus. Disabled buttons are also problematic for accesibility as far as I found. As long as adding items is allowed this patch keeps focus on the open button. When the open button is removed the focus is set to the remove button of the first media item. The announcement also mentions the maximum number of allowed items is reached. Hopefully this is clear enough.
Comment #4
seanbFound a related issue that causes the upload form to break #2504115: AJAX forms should submit to $form['#action'] instead of <current> when the add form is loaded via an AJAX callback.
The attached patch should fix this.
Comment #5
andrewmacpherson commentedThis issue has a broad title, and is a spin-off from a review issue with a similar broad title, to fix some of the issues found there.
Manual accessibility testing is time consuming, and having an issue where points 1-5 here relate to points A1-A2 and A11-A13 on the parent is just going to hold up accessibility review. There's a good chance reviewers will get lost, or confused about what's been addressed.
Can we give this a specific title about what it is fixing? Also narrow the scope and use separate child issues for the parent.
Comment #6
andrewmacpherson commentedAlso, please tag the spin-off issues from the parent, otherwise the implementation won't get the attention people who want to contribute to accessibility.
Comment #7
andrewmacpherson commentedI'm getting lost already, keeping track of the numbers when jumping between the problem and resolution lists,
Please separate this into 5 issues. None of them are remotely related to each other, and they a mix of major and minor. There are possible quick-wins, and some which will require a bigger manual testing effort across multiple assistive tech or input modalities.
Comment #8
andrewmacpherson commentedComment #9
andrewmacpherson commentedI've started breaking this up into separate issues. Created these two..
#3035434: Improve name of MediaLibraryWidget dialog
#3035435: Make the show/hide row weights button more informative for assistive tech users.
Comment #10
andrewmacpherson commentedI think we can treat #3016807: Improve refocus on submit buttons of Media Library Widget modals as the issue for "After selecting items from the library the focus shifts to the save button of the parent form. I would expect to be back in the widget to verify my selection". There's already plenty analysis there.
Comment #11
andrewmacpherson commentedFiled #3035446: Inform assistive tech users about the outcome of using the MediaLibraryWidget dialog to address "The text 5 items remaining is part of the element description but below the add button. After changing the selection the number of remaining items are not communicated to the user."
Which leaves this issue as "‘Add media’ in widget should be a button, not a link".
Comment #12
seanbThanks @andrewmacpherson. Attached a new patch with just to changes to add a button instead of a link. Since the media library is now no longer opened via a URL I needed to make extra changes to make sure the MediaLibraryState object can be passed around to various parts of the library. I think this it's a good thing we found this.
Update: To be more specific, the media add form and the view in the media library were fetching the state from the request instead of getting it passed from the media library UI builder. I consider this to be a bug we uncovered and fixed to implement this issue.
The actual code changes to fix the bugs are:
Comment #13
phenaproximaIt turns out this is dead code which should have been removed when we added vertical tabs to the media library. Keeping it here breaks this patch anyway, so I'm glad this is getting cleaned up now.
I get the feeling that the media_library/widget library should declare an outright dependency on core/drupal.dialog.ajax; I'm not sure under what circumstances it wouldn't need it. On the other hand, if we do that, we'll also need post-update hook in order to ensure that the library definition is refreshed. So maybe that is out of scope for now, and can be done in a follow-up (linked in the code here).
This comment is wacky :) It should say "Allow the media library to be opened even if there are form errors."
Why is this needed? Couldn't we still just
return $element, as long as the #ajax wrapper is set elsewhere?The service should be injected.
This line could use a comment. Also, is there any constant somewhere that refers to #drupal-modal, so that we don't need to hard-code it here?
I think this comment needs to be expanded, at least with a @see so we know where it's being used, and how.
Comment #14
andrewmacpherson commented#12 - right, that all sounds like a big job which has benefits outside of a11y.
As far as the a11y triage, this one is a should-have rather than a must have. Confusion between links and buttons is a frustration for lots of assistive tech users, but not a brick-wall barrier. Many screen reader users are accustomed to the fact that developers use links and buttons interchangeably.
If it's too difficult to change this to a proper HTML
<button>, another option is to use<a role="button">but then it needs an extra keypress handler so it responds to the spacebar as expected. A HTML<button>is still preferred; the first rule of ARIA is don't use ARIA.Updating issue summary, and parent issue with a11y should-have triage.
Comment #15
andrewmacpherson commentedAlso re. #12:
If you need to rescope the issue as an architectural change for robustness, that's ok. The button-vs-link issue can be called the initial use-case which needs it.
Comment #16
seanbIt actually wasn't that big of a change. There were 2 places using the request object directly to get the MediaLibraryState instead of getting it passed from the media library. I wouldn't call it an architectural change, more like a bug we uncovered by doing this.
I'll update my comment to better reflect this.
Comment #17
seanbNW for #13.
Comment #18
seanb#13
1. Turns out I was wrong and we still need this code when filtering and sorting the view. Sorry about that.
2. Fixed. Do we really need a post update, we already added a bunch of library changes without that?
3. Fixed.
4. Fixed. In a previous patch the announcement and focus were also set here, but those are other issues now.
5. This is a static method.
6. Fixed.
7. Fixed.
Comment #20
seanbFixed the tests added in #2996029: Add oEmbed support to the media library. Also implemented a better fix for #2805219: Some dialogs do not receive focus when opened on the open button now I actually know what the problem was.
Comment #21
andrewmacpherson commentedCan you please explain this? There are a bunch of other dialogs that need fixing too - please comment at [#1805219].
Also, both of those changes seem out of scope for this issue.Update: sorry, I understand what the test fixes are about now.
Comment #22
andrewmacpherson commentedNeeded a re-roll since #2989503: Add tests to prove that the media library widget works when target_bundles is NULL was committed today.
Comment #23
andrewmacpherson commentedPatch #20 affects a couple of files in Layout Builder module, which surely isn't right.
The interdiff in #20 isn't right. Here's what I get by comparing #18 and #20.
Comment #24
seanbI forgot to pull the latest 8.7.x changes in my branch before creating 3035316-20.patch. Sorry about that. Rerolled and made sure I didn't forget this time. New patch attached.
I think you mean #2805219: Some dialogs do not receive focus when opened? Also left a comment there, but just to be clear. Here is a copy of that comment:
-------------------------
Just found out what the problem was for the media library. By default, jQuery UI dialog moves the focus to the first tabbable element in the dialog, which is good.
In
core/misc/ajax.jshowever, we have code to move the focus to the element that triggered an AJAX request.So, in order to fix this problem, elements triggering a dialog need to set the data attribute
data-disable-refocustotrue.We could also change
core/misc/ajax.jsto skip refocus when a dialog is opened, but there is a good chance this could break implementations already working around this problem. For now I've at least added the data attribute to the patch changing the media library open button in #3035316: ‘Add media’ in MediaLibraryWidget should be a button, not a link. We should probably continue the discussion here to see if there is a generic way to fix this without breaking existing implementations.Comment #25
andrewmacpherson commentedThis patch updates #20.
The exact way I did it was:
Comment #29
seanbThink we cross-posted. #24 seems to be green, back to needs review for that one.
Comment #30
phenaproximaNice future-proofing. :)
Can't find anything else glaringly wrong with the code in this patch. Once accessibility review is complete, this is RTBC.
Comment #31
andrewmacpherson commentedI'm having trouble applying this patch for manual testing...
None of the patches from #24 or #25 apply now.
I've lost track of exactly which patch is which, so I've assumed that @seanb's patch from #24 is the best one.
It's currently green, but fails to apply on my machine, and I currently get a 403 access denied when I try to requeue tests here.
I got confused looking at git
*.rejtrying to re-roll it.I'll have to come back to this later. Can one of you try a re-roll if needed?
I don't think this makes sense. Isn't it a "callback to open the widget when the button is pressed"?
Comment #32
oknateRerolling #24. There was one conflict in MediaLibraryTest around line 489. I think #24 was adding an extra assertWaitOnAjaxRequest() (which I kept).
I think testbot is out of commission today, FYI. Also, I was just re-rolling and adding text change based on #31. I haven't tested the patch.
Comment #33
seanbAnother reroll for #24. Also fixed the nit from #31.
Not sure what happened with with the reroll in #32, but the quickest way for me to fix it was to start from the last working patch. Sorry!
Comment #34
rainbreaw commentedseanB and phenaproxima showed this one to me on a google hangout today for accessibility review, as well. In this patch, the code is using
input type="submit"(which is a native HTML button), and behaving as expected.We discussed the relationship of this issue to #3016807: Improve refocus on submit buttons of Media Library Widget modals. #3016807: Improve refocus on submit buttons of Media Library Widget modals is, in essence, blocked by this issue unless doing a workaround with a fake item, which increases the priority of this item.
Comment #36
phenaproximaThis now officially blocks #3016807: Improve refocus on submit buttons of Media Library Widget modals, so I'm escalating it to the same priority.
Comment #37
phenaproximaAfter this change, I think AddFormBase.php will no longer need to
usethe MediaLibraryState class, so can we remove the use statement?Looks correct to me otherwise. Now that we have run this through an accessibility review, RTBC once this is fixed.
Comment #38
seanbRan the code check and removed some use statements that were no longer needed.
Comment #39
phenaproximaNice.
Tagging for backport to 8.7.x since this is a major accessibility improvement in an experimental module, and therefore may be eligible to land in alpha.
Comment #40
alexpottCommitted and pushed 58d6b44288 to 8.8.x and 379e676d9b to 8.7.x. Thanks!
This looks like a good change and unblocks more media library work - go team :)
Credited @phenaproxima for code review and @rainbreaw for jumping on a call to discuss accessibility - thanks!
Comment #43
phenaproximaComment #46
alexpott@phenaproxima asked for a revert as an AJAX bug has been found.
Comment #47
phenaproximaTagging for tests and a fail patch.
Comment #48
seanbAttached is a fix for the issue. The cause is this is #2504115: AJAX forms should submit to $form['#action'] instead of <current> but there are ways to work around that problem. Please review!
Comment #49
phenaproximaThis comment is a bit confusing. I would suggest we rephrase it thusly: "The media library is loaded via AJAX, which means that the form action URL defaults to the current URL. However, to add media, we always need to submit the form to the media library URL, not whatever the current URL may be."
Wouldn't $assert_session->elementNotExists('css', 'media-library-add-form-selector') be a little more robust here?
Same here?
Comment #50
seanbFixed #49.
Also noticed a new issue with the solution introduced in #48. Since we are now using the media library state to create the #action URL, we must validate the presence there as well (not in
getMediaType()like before). To fix this, I've added a newgetMediaLibraryState()method to the form that can now be called instead of using$form_state->get('media_library_state')directly.The fail patch is still 3035316-48-test-only.patch. The attached patch fixes the state validation issue introduced in #48.
Comment #53
phenaproximaThis needs a
@throwsclause to explain why the InvalidArgumentException is thrown.My only other question here is this: I don't quite see how the tests are covering the regression we are trying to fix since this got reverted. As I understand it, the problem would manifest if you open the media library and immediately try to add media, without changing to another tab. Are our tests actually testing that interaction? I imagine that they are not, because if they were, we would presumably have caught this bug before the initial commit.
Comment #54
seanbAdded
@throwsto the doc blocks (getMediaType()also needed it).This is the part that removes the click on a tab before uploading, which caused 3035316-48-test-only.patch to fail.
Comment #55
phenaproximaOkay. I feel pretty confident about this. The fail patch makes sense; @seanB showed me where we are changing the tests to ensure that an upload works even if you have not changed tabs (which is what manifested the AJAX bug we have subsequently fixed). Sean also tells me that we test what happens if, after that initial upload, you click to another tab and add more media (it's the part preceded by the comment
Verify we can only upload the files allowed by the media type.).RTBC when green.
Comment #56
alexpottI think it is worth adding a comment that we are testing uploading from the initial media library form before clicking on any tab. It'd be pretty easy to add this click back in and lose this test coverage.
Comment #57
seanbChanged the comment to make it clear we are testing the default tab.
Comment #58
phenaproximaComment #59
alexpottCommitted and pushed 05fa218275 to 8.8.x and b159f8162e to 8.7.x. Thanks!
Thanks for addressing the regression so quickly and new test coverage ftw.
Comment #63
sam152 commentedFor the benefit of any watchers, I've filed a follow-up bug which I believe was caused by this #3094059: The media library widget "Add media" button incorrectly submits form handlers of forms it is embedded in.