Spin-off from #2988431: [Meta] Accessibility plan for Media Library Widget.

Problem/Motivation

After clicking the hide/show row weights in tabledrag, the UI changes (weight stepper fields and draggability are toggled) but these changes are not made apparent via screenreader. The screenreader should announce these changes.

Proposed resolution

Make the changes triggered by show/hide row weights announced to screenreaders.

Remaining tasks

TODO

User interface changes

TODO

API changes

none

Data model changes

none

Issue fork drupal-3035435

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:

Comments

andrewmacpherson created an issue. See original summary.

andrewmacpherson’s picture

Issue tags: -accessibility +Accessibility

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

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mgifford’s picture

So we could just use DrupalAnnounce() to tell the user what happened. Would that be sufficient?

rainbreaw’s picture

I think DrupalAnnounce() would be an excellent solution, as once you tab through the logic does become relatively clear.

The announcement would be something to the effect of

A weight stepper field is now present with each media entity listed.

One other challenge is that the weight stepper fields do not have any label indicating what they are stepping the weights for. It would help if the filename were added, so that it would read something like

Weight, stepper for [filename]

bnjmnm’s picture

Status: Active » Needs review
StatusFileSize
new3.33 KB

This patch provides the functionality suggested in #5. An announcement is triggered when the show/hide weights is toggled, and the weight stepper field has a more descriptive label for screenreaders.

wim leers’s picture

I'm surprised this is being added to the Media Library's code. We've got these weight toggles literally everywhere in Drupal's admin UI. Why aren't we doing it in a generic way, to solve this everywhere?

I can see either of these:

  1. We do not do this generically because the announcement string needs to be tuned for the specific UI the user is interacting with.
  2. We do not do this generically yet and do that in a follow-up. Then this needs a follow-up created.
  3. We change this patch to do it generically.

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.

bnjmnm’s picture

#7

Why aren't we doing it in a generic way, to solve this everywhere?

no good reason - that's a much better way to go about this.

This new patch changes tabledrag and adds test coverage. No interdiff as it's a 100% different patch.

joachim’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

Looks like a good fix, but setting to needs work based on #7. This should be done for the tabledrag functionality in general.

Also, the issue summary doesn't explain what's being done here.

bnjmnm’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new2.86 KB

Forgot to actually upload the patch in #9. Here's that, plus I updated the issue summary.

dww’s picture

Mostly the patch in #11 looks good. A few concerns:

A) I'm not clear how to test this manually. ;) I don't have a screen reader. I'm not sure how to inspect the results of DrupalAnnounce(). Any pointers on that?

B) Patch #6 did this:

+            // Provide a more descriptive label for screenreaders, added as an
+            // aria-label because the label template would strip the markup
+            // that provides the .visually-hidden class.
+            'aria-label' => $this->t('Weight, stepper for @label', ['@label' => $media_item->label()]),

There's nothing like that in #11. Is it possible to have a general purpose solution for this, or would we have to change all the forms that make use of tabledrag?

That said, I'm not totally sure we need it. When inspecting the source for a tabledrag-enabled form in 8.9.x core with this patch applied, I'm already seeing this:

<tr class="draggable tabledrag-leaf" data-drupal-selector="edit-fields-title" id="title">
                      <td>Title</td>
                      <td><div class="js-form-item form-item js-form-type-textfield form-type-textfield js-form-item-fields-title-weight form-item-fields-title-weight form-no-label">
      <label for="edit-fields-title-weight" class="visually-hidden">Weight for Title</label>
        <input class="field-weight form-text" data-drupal-selector="edit-fields-title-weight" type="text" id="edit-fields-title-weight" name="fields[title][weight]" value="0" size="3" maxlength="128" />
        </div>
</td>
...

So we've got <label for="edit-fields-title-weight" class="visually-hidden">Weight for Title</label> which seems like it should be sufficient for the concerns in #5. Did this label change in the last few months, do I misunderstand comment #5, or did #5 miss this markup somehow? Is it totally form-dependent? In my case, I'm looking at /admin/structure/types/manage/article/form-display -- I haven't dug into what layer in the system is handling that <label>.

Finally, should we leave this tagged for needing a summary update until all the TODO is spelled out? Other than being slightly incomplete, the changes from #11 seem clear and good. I was going to remove the tag, but the TODOs made me think twice. ;)

Thanks!
-Derek

Status: Needs review » Needs work

The last submitted patch, 11: 3035435-11.patch, failed testing. View results

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.

vsujeetkumar’s picture

Status: Needs work » Needs review
StatusFileSize
new2.82 KB

Re-roll patch created for 9.1.x

Status: Needs review » Needs work

The last submitted patch, 15: 3035435_15.patch, failed testing. View results

vsujeetkumar’s picture

Status: Needs work » Needs review
StatusFileSize
new2.85 KB
new1.19 KB

Fixing test, Please review.

tanubansal’s picture

Patch #17 is working fine on 9.1

andrewmacpherson’s picture

I don't think this is a very good approach. Drupal.announce() is a useful last resort for information which can't be conveyed any other way, but it isn't the first tool we should reach for. It comes with a major disadvantage; the user doesn't find out about the behaviour until after they have activated the control. Good controls inform the user of their purpose, state, and behaviour before you activate them.

With patch #17 here:

  1. I encounter a button called "show row weights".
  2. I press it, and Drupal.announce() says weights are now shown. No surprise there, it did what it said on the button.

That doesn't add any clarity. It's just more words.

More importantly though, it still doesn't convey the entire behaviour of the button. The name of the button refers to the row weight fields, but it actually controls the behaviour of TWO things: the row weight fields, and the pointer drag-handles. The effect on the drag-handles isn't conveyed at all.

Another problem: it's a single button whose name changes. These aren't ideal, because they conflate the name of the control with the current state in a confusing way. When I encounter a button called "hide row weights", I have to do a mental hop to infer that the row weights are currently shown. The button name reflects the opposite of the current state. This problem is described by Leonie Watson describes in a webinar:

"Toggle buttons are really hard. Play/pause buttons are the notorious example. I hit "play" and then the button appears to be pressed, and then something starts playing. But then the label changes to "pause" and I'm never quite sure whether the pause button means if I hit it it will pause, or whether it's already paused and if I hit it, it will go back to play. Something like aria-pressed is a good way of saying keep the label the same, but indicating along with the visual design that this thing is pressed or not-pressed."

Source: How A Screen Reader User Accesses The Web (approximately 54 minutes into the video).

Compare this with some of the "toggle" buttons we have in Drupal core:

  • "Show descriptions / hide descriptions". We have these on the the admin/config index page, and the permissions page.
    • The behaviour is: FOO-ON versus FOO-OFF.
    • The behaviour resembles the semantics of a checkbox. Using this avoids the problem of conflating the control's name and state, for both sighted and blind users.
    • Optionally the checkbox could be themed as an iOS-style toggle. If so, use role="switch" too.
    • Alternatively, a button with a constant name ("show descriptions") with current state conveyed using aria-pressed="true|false". This follows the suggestion from Leonie Watson's webinar, but it has more moving parts, and needs extra styling to convey the state to sighted users.
  • "Show row weights / hide row weights", on the draggable tables.
    • This one isn't behaving as a simple on/off switch. It controls the presence of the row weight fields, and the drag handles.
    • So the behaviour is choice of two things: SHOW-FOO versus SHOW-BAR.
    • This behaviour resembles the semantics of a pair of radio buttons, or a <select>.
    • Optionally, it could have some fancy styling to resemble a slide-toggle
    • A button with aria-pressed="true|false" isn't sufficient to describe this behaviour.

I propose that we change the row-weights button to a radio button group, to convey that 2 alternative tools are available.

I also think that our "show descriptions" toggle buttons could be improved by using checkbox semantics. We could to that in a separate issue, or expand the scope of this one. Thoughts?

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.

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
StatusFileSize
new144 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.

mgifford’s picture

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.

Ratan Priya’s picture

StatusFileSize
new2.25 KB
new2.25 KB

Re-rolled #17 to 11.x-dev

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.