Problem/Motivation

Simple copy of $variables['summary_attributes']['aria-expanded'] lead to dupliction of aria-expanded attribute on resulting tag and the loss of the aria-pressed attribute.
These two aria attributes have an important impact on accessibility of collapsible fieldsets like those used everywhere in Drupal.

Steps to reproduce

  1. run Drupal installer
  2. go to the 'Database configuration' page
  3. see the 'Advanced options' <summary> HTML code (but do not open it or JS is going to hide the issue)

Proposed resolution

From my point of view, this is proper solution:
$variables['summary_attributes']['aria-pressed'] = $variables['summary_attributes']['aria-expanded']->value();

To avoid that kind of issue to be randomly reproduced, fix the Drupal\Core\Template\Attribute::createAttributeValue(). So, if the provided value is already an AttributeValueBase object, we create a new object with the right name and copy the value instead of returning the provided one.

Remaining tasks

Contributor tasks needed
Task Novice task? Contributor instructions Complete?
Create a patch Instructions Done
Update the issue summary Instructions Done
Update the issue summary noting if allowed during the rc Template Done
Add automated tests Instructions Done
Manually test the patch Novice Instructions Done
Add steps to reproduce the issue Novice Instructions Done
Embed before and after screenshots in the issue summary Novice Instructions Done
Review patch to ensure that it fixes the issue, stays within scope, is properly documented, and follows coding standards Instructions Done

User interface changes

None. (Some invisible markup changes)

API changes

None.

Data model changes

None.

Why this issue should be an rc target

This is an accessibility issue, but also just about fixing up some embarrassing & redundant code that is all over the admin side of Drupal 8. Anytime there's a Detail/Summary element there will be some bad markup. The duplicate aria-expanded isn't as critical as the missing aria-pressed attribute. aria-pressed Indicates the current "pressed" state of toggle buttons. aria-expanded indicates whether the element, or another grouping element it controls, is currently expanded or collapsed.

Before patch:

After patch:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

IRuslan created an issue. See original summary.

IRuslan’s picture

IRuslan’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: wrong-attributes-in-preprocess-details-2605420-2.patch, failed testing.

IRuslan’s picture

Status: Needs work » Needs review
cilefen’s picture

Issue tags: +Accessibility, +aria

I am tagging this "accessibility" to get it a little more attention.

mgifford’s picture

What is the best way to see this with/without the patch?

IRuslan’s picture

How to check:
During Drupal install go to Database configuration page. Check the page source. You will see summarry HTML tag with 2 same aria-expanded attributes.
Apply patch, reload the page and look into source – you will see 2 different attributes, aria-expanded and aria-pressed. Which is corrrect.

mgifford’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
Issue tags: +Quick fix
FileSize
207.65 KB
228.54 KB

Makes sense to me. This is clearly wrong:

<details data-drupal-selector="edit-mysql" id="edit-mysql--2" class="js-form-wrapper form-wrapper"><summary role="button" aria-controls="edit-mysql--2" aria-expanded="false" aria-expanded="false">Advanced options</summary><div class="details-wrapper">

This is way better:

<details data-drupal-selector="edit-mysql" id="edit-mysql--2" class="js-form-wrapper form-wrapper"><summary role="button" aria-controls="edit-mysql--2" aria-expanded="false" aria-pressed="false">Advanced options</summary><div class="details-wrapper">

Seems like a simple fix.

mgifford’s picture

Status: Reviewed & tested by the community » Needs review

Actually, let's test this a bit more. Is this patch going to throw off anything else that uses template_preprocess_details?

joelpittet’s picture

@mgifford it's not, the RTBC is correct fix, because it's passing the object by reference any changes would affect the other. This will create a new object.

The only thing we could look at is maybe what should be expected? Maybe this should always clone/grab the value?

I'm throwing up a fix that is a bit more generic, if this passes it may need test coverage and another manual test @mgifford if you're up for it?

DuaelFr’s picture

I just marked #2548309: aria-expanded="true" added twice as duplicate of this one.
Some work started there during a little sprint this summer but we were not able to reproduce.

mgifford’s picture

Status: Needs review » Needs work

@joelpittet with the patch, I still get aria-expanded="false" aria-expanded="false"

IRuslan’s picture

Status: Needs work » Needs review
FileSize
690 bytes

Clone approach will not work in the current design of Attribute class — name also will be to cloned, and there is no way to set up a different name after.
I propose to create a new instance of required class directly with value from object to clone from, but with the proper name.
See patch.

IRuslan’s picture

Corrected comments to this block a bit.

Status: Needs review » Needs work

The last submitted patch, 15: wrong-attributes-in-preprocess-details-2605420-15.patch, failed testing.

joelpittet’s picture

Status: Needs work » Needs review

@IRuslan you are totally right, thanks a bunch. @mgifford does that fix it for the manual testing? I'd expect it should have the same value but the name should be the new one.

joelpittet’s picture

joelpittet’s picture

I don't know if this is totally necessary to get into RC, it could easily go into 8.0.1 or something though. Tag it with 'rc target triage' if you can put some rational behind it's inclusion.

The last submitted patch, 11: wrong_usage_of-2605420-11.patch, failed testing.

The last submitted patch, 18: wrong_usage_of-2605420-18-tests-only-fail.patch, failed testing.

mgifford’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
Issue tags: +rc target triage
FileSize
100.55 KB
73.66 KB

That fixes the problem with the install page. Tested it also in /admin/config/people/accounts

Before patch:

After patch:

I think this is ready to go.

xjm’s picture

Issue tags: -rc target triage

Discussed with @effulgentsia. The problem described in the summary doesn't seem sufficient to us for this to necessitate a change during RC. If there is a more specific accessibility bug beyond that, such that it actually impaired the functionality, please add that information to the summary and retag the issue. Thanks!

mgifford’s picture

Ok, I'm just wondering when this simple change could get in then.

Can it come in at a 8.0.1 release? It's an annoying redundant bug that just looks bad and doesn't help.

I can just see changing this later causing a lot more work down the line.

joelpittet’s picture

Yes likely @mgifford.

Though if update the issue summary to the proposed latest patch it may get in in RC target.

As the summary doesn't show the nature of the bug.

mgifford’s picture

Title: Wrong usage of Attributes instance in template_preprocess_details() » Double aria-expanded in template_preprocess_details()
Issue summary: View changes
Issue tags: -Needs manual testing +rc target triage

Taking a suggestion from twitter.

@xjm I hope that this clarification helps.

DuaelFr’s picture

I'd add that this patch only affects markup and contains tests that illustrate the bug. It's not disruptive at all and has been manually tested a lot.

As Mike said, it's not critical but the more accessible and clean we are at the time of the release, the more exemplary we seem for both the a11y and the front end world.

xjm’s picture

Title: Double aria-expanded in template_preprocess_details() » Missing aria-pressed template_preprocess_details() due to lost copied attributes in Attribute
Issue tags: -rc target triage +rc target, +Needs issue summary update

So having a duplicated attribute really did not seem important enough to fix during RC, but @effulgentsia walked me through the test coverage and I can see how the broader bug (and the loss of the aria-pressed attribute) make this reasonable as an RC change. It could also go into a patch release safely (i.e. 8.0.1).

Also tagging for issue summary update since some bits of the summary are incorrect, others are unclear, and the full scope of the bug isn't covered. Leaving at RTBC though since @effulgentsia seems to have a handle on this issue now.

DuaelFr’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.0.x, thanks!

Status: Fixed » Needs work

The last submitted patch, 18: wrong_usage_of-2605420-18-pass.patch, failed testing.

joelpittet’s picture

Status: Needs work » Fixed

Silly testbot, tricks are for kids.

mgifford’s picture

So great that this is fixed! Thanks @joelpittet for the bunny jokes. :)

  • catch committed 19e1f2f on 8.1.x
    Issue #2605420 by IRuslan, joelpittet: Missing aria-pressed...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.