Problem/Motivation

When @cboyden's team did an assistive tech walkthrough of Media Library for #2834729: [META] Roadmap to stabilize Media Library using NVDA on Firefox, we discovered that, when making selections of items in the library, if you have met the max and remaining items are grayed out (disabled), a screenreader user is still able to select the disabled items, hearing them as "clickable".

This problem is only present if you are using a screenreader (tested with NVDA). This is not something that a mouse user will encounter because the disabled items cannot be clicked by the mouse to select. Keyboard-only users cannot select the items either.

This problem becomes especially confusing because the screenreader user is not given any kind of warning or alert that they have made selections beyond what is possible. Once they select more than the limit, the remaining items are no longer disabled and grayed out, so they might select an unlimited number. The system does not show an error message in the modal when more than the limit are selected.

After activating "Insert selected" button, the system announces "Added X media items," but the field is actually empty. If they go so far as to save the node, then it saves, but no media is added. The error that should have appeared on the modal displays on the node page, but is not announced.

This interaction can be viewed on the video recording of the September 29, 2019 walkthrough of Media Library starting at around minute 6:30 and continuing to minute 9:45..

Proposed resolution

TBD

Remaining tasks

  • Determine resolution and implement.

User interface changes

The way that the Media Library presents each selectable media item may need to be adjusted slightly so that the entire element, including the image and the checkbox, are only available through keyboard access as a single element.

API changes

None anticipated.

Data model changes

None anticipated.

Release notes snippet

TBD

Issue fork drupal-3084560

Command icon 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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rainbreaw created an issue. See original summary.

cboyden’s picture

Title: Ensure that when the Media Library disables media items so that they cannot be selected, that they are also disabled for keyboard-only/screenreader access » Ensure that when the Media Library disables media items so that they cannot be selected, that they are also disabled for screenreader access
Issue summary: View changes
Issue tags: -keyboard

Updated issue summary - added details of screenreader interaction and error messages. We weren't able to trigger the error with the keyboard on Chrome or Firefox on Mac.

bnjmnm’s picture

Status: Active » Needs review
Issue tags: +Needs accessibility review
FileSize
5.51 KB

Although I can't reproduce the exact error on my Mac using Voiceover, I could select more than my share of items by navigating with voiceover to parts of a disabled element using VO-arrow (not Tab navigation) then hitting return on any element other than the checkbox field.
The issue summary reporting NVDA announcing "clickable" suggests this is due to a click event listener still being present on the Media Item, even if clickability/keyboard nav is disabled. This patch removes the click listener when the item is disabled, and returns it if it becomes re-enabled. This fixed the similar issue I experienced with Voiceover, but I'll need confirmation from someone experiencing the exact issue reported to confirm it is fixed for them as well. It would also be good to know if there's a better way of communicating what is happening to screenreader users - this patch should put out the fire of too many items being added but the screenreader experience is largely unchanged (aside from hopefully eliminating the "clickable" said by NVDA).

Status: Needs review » Needs work

The last submitted patch, 3: 3084560-3.patch, failed testing. View results

bnjmnm’s picture

Status: Needs work » Needs review
FileSize
7.8 KB
9.05 KB

Fixed the test failure which exposed:

  • The need for a main media library js file that all js files have as a dependency. The click listener was added to this.
  • When the click listener is removed from disabled items, any links in it become clickable, so an onclick attribute is added to links when they are inside a disabled item.
rainbreaw’s picture

I'm pinging @cboyden to review this one

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

cboyden’s picture

Lucy and I reviewed the patch. The disabled elements are still announced as "clickable," but, clicking on the "clickable" elements no longer does anything. The NVDA user is no longer able to select more items that are allowed by the field.

For each library item, there are two clickable elements that are available when using NVDA's arrow navigation. Either one works to select the item. It would make for better screenreader usability if there were only one actionable element per media item.

rainbreaw’s picture

Status: Needs review » Reviewed & tested by the community

Thank you @cboyden and Lucy for reviewing and confirming that the essential problem of this issue is resolved. I have created a new issue — #3087528: Adjust the listed items available in the media library so that there is only one clickable/focusable element per item — targeting the additional challenge that you reported in comment 8.

rainbreaw’s picture

(comment removed)

phenaproxima’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Looks like this needs to be rerolled.

oknate’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
9 KB

Reroll of #5 (only).

One thing I noticed:

+        console.log('disable items', $items);

console.log should be removed.

Dinesh18’s picture

Here is the patch which removes the console.log. Kindly review.

phenaproxima’s picture

Issue tags: +Amsterdam2019

Tagging this important bug fix to be worked on at DrupalCon Amsterdam.

bnjmnm’s picture

Tested on NVDA and was able to address the disabled items having content still reported as "clickable"

bnjmnm’s picture

Issue tags: +Needs manual testing

Tagging this with "needs manual testing" -- it's not possible to cover this with FunctionalJavascript tests as the problem is only present when screenreaders are enabled.

With NVDA enabled, it becomes (pre-patch) possible to tab into the disabled media items and the return key would select the item.
With Voiceover, the items can't be accessed via tab navigation, but can be via VO-arrow, and the return key can select the item as well.

phenaproxima’s picture

  1. +++ b/core/modules/media_library/js/media_library.main.es6.js
    @@ -0,0 +1,32 @@
    +    /**
    +     * When a user interacts with the media library we want the selection to
    +     * persist as long as the media library modal is opened. We temporarily
    +     * store the selected items while the user filters the media library view or
    +     * navigates to different tabs.
    +     */
    +    currentSelection: [],
    +    /**
    +     * Media item click listener that is used in multiple files.
    +     *
    +     * @param {object} event
    +     *   The click event.
    +     */
    +    clickToSelectTriggerEvent: event => {
    

    Nit: Can these things be separated by an empty line?

    Also, I'm not sure about the naming of clickToSelectTriggerEvent. I would probably go with something like onSelectMediaItem or similar, since it is an event handler.

  2. +++ b/core/modules/media_library/js/media_library.ui.es6.js
    @@ -293,7 +280,14 @@
    +          .find('a')
    +          .attr('onclick', 'return false;')
    +          .attr('aria-disabled', true)
    +          .attr('tabindex', '-1');
    

    Nit: I think all of these attr calls can be combined into one, since attr accepts an object of key-value pairs.

    One thing I'm not certain about it setting the onclick attribute to a string of JavaScript. Can't we just use .on('click', () => return false)?

    Another thing here is that I'm not sure we need the onclick stuff at all. Is aria-disabled not sufficient for our purposes?

    One final request is for this to get a nice long comment documenting what we're doing and why. :)

seanB’s picture

One thing I'm not certain about it setting the onclick attribute to a string of JavaScript. Can't we just use .on('click', () => return false)?

I was also thinking about this. We should actually remove href attribute from the link, or maybe even remove the link entirely for disable items. I think removing the href would already be enough and setting a data-href attribute temporarily for disabled items could be a nice workaround.

This would also solve Lucy and I reviewed the patch. The disabled elements are still announced as "clickable," but, clicking on the "clickable" elements no longer does anything. The NVDA user is no longer able to select more items that are allowed by the field. from #14.

bnjmnm’s picture

Addressed the feedback in #17
Great call in #18 on removing href, that takes care of it and the JS is cleaner. However, it should be mentioned that I discovered that these links don't even work in dialogs in #3087528: Adjust the listed items available in the media library so that there is only one clickable/focusable element per item. My proposal there is to change those to regular text, which would impact this solution. For now, the hrefs are getting removed and that seems to work well.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

ranjith_kumar_k_u’s picture

I have tested this issue in Drupal 9.1.x-dev with "Orca Screen Reader"(through keyboard). I could select only the allowed number of items. When I selected the allowed number of items, all the other items were disabled for selection but we can navigate through those disabled items. The disabled items were still announced as "clickable", but actually clicking on those "clickable" items no longer does anything.

Video Link:https://drive.google.com/file/d/1pxO3AvSmCtYsrdPEIQQrFpwFPgwfbTsJ/view?usp=sharing

phenaproxima’s picture

janmejaig’s picture

I have check above issue and found that , this issue is related to "issues-3059955" . Once this related issue(3059955) will get resolved this ticket will be also get resolved .

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

nishantghetiya made their first commit to this issue’s fork.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
149 bytes

The 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.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.