Repeatable: Always

Steps to repeat:
1. Create and enable a minimal Stable sub theme e.g. 'minimal'. This theme should not contain its own
block--system-menu-block.html.yml in its templates folder.
2. Check for accessibility e.g. with Accessibility Developer Tools or Wave

Expected Results:
No severe problems as it is the case when using Classy or Bartik as base theme.

Actual Results:
Checking accessibility with Accessibility Developer Tools reveals a broken ARIA reference in all menu blocks.
This is caused by a missing id attribute of a <h2> which is referenced by the <nav> ARIA attribute 'labelled-by'
(see image below)

 missing id for aria attribute

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jo.st created an issue. See original summary.

jo.st’s picture

Comparing block--system-menu-block.html.yml of Stable and Classy the two files differ in two ways:
As expected more classes for Classy, but also this difference:

Classy
<h2{{ title_attributes.setAttribute('id', heading_id) }}>{{ configuration.label }}</h2>

Stable
<h2{{ title_attributes }}>{{ configuration.label }}</h2>

I don't think this is intended, because besides this line, the Stable version contains all necessary code to implement the pattern 'Add aria-labelledby to <nav> elements' like Classy actually does.

I created a patch that completes this line in Stable according to Classy, which fixes the issue.

jo.st’s picture

Status: Active » Needs review
andrewmacpherson’s picture

Issue tags: +Accessibility
andrewmacpherson’s picture

@jo.st Thanks for the patch and steps-to-reproduce.

This problem also affects the equivalent template from system.module, and you can replicate the problem using the Stark theme. Running the Chrome #a11y audits with the Stark theme tells us that this problem affects all 4 menu blocks (on homepage, after a standard install, then enabling Stark).

It looks like this was broken by #2407715: Remove classes from system templates b*.html.twig. That purpose of that issue was to remove some classes but it stripped some ID attributes out as well. The stable theme just inherited the problem when the templates were copied from the core modules just before the 8.0.0 release.

git show af53fb6 says another nav heading ID was stripped from the breadcrumb template at the same time.

The patch in comment #1 is the right approach, however we should also fix it in the core system.module templates. Affected templates:

  • core/modules/system/templates/block--system-menu-block.html.twig
  • core/modules/system/templates/breadcrumb.html.twig
  • core/themes/stable/templates/block/block--system-menu-block.html.twig
  • core/themes/stable/templates/block/breadcrumb.html.twig
andrewmacpherson’s picture

Title: Broken ARIA reference in Stable menu blocks » Broken aria-labelledby ID reference in menu block and breadcrumb templates
Version: 8.2.x-dev » 8.1.x-dev
Component: Stable theme » system.module
Status: Needs review » Needs work
Issue tags: +stable

Updating the title as it affects several templates.

The bug should be fixed in the system.module.

Tagging so stable theme maintainer still sees it. The stable theme templates aren't supposed to change, however this bug might qualify. We're restoring some functional (non-styling) ID attributes that shouldn't have been removed.

This is a bug fix, so eligible for 8.1.x I think.

jo.st’s picture

Thanks @andrewmacpherson.
I fully agree, fixing this bug in 8.1.x, both in core system.module templates and stable would be an improvement.

This patch adresses the core system.module templates

  • core/modules/system/templates/block--system-menu-block.html.twig
  • core/modules/system/templates/breadcrumb.html.twig
jo.st’s picture

This patch adresses the Stable templates

  • core/themes/stable/templates/block/block--system-menu-block.html.twig
  • core/themes/stable/templates/block/breadcrumb.html.twig

In both patches I completed the the code according to the working patterns of Classy. No further changes.

jo.st’s picture

Status: Needs work » Needs review
star-szr’s picture

Thanks for the tag @andrewmacpherson I agree this seems like the type of thing we would want to fix in Stable and I see little to no risk in making this change.

andrewmacpherson’s picture

@cottser Great, thanks for confirming this.

andrewmacpherson’s picture

Status: Needs review » Needs work

@jo.st

Good news - we have sign-off from the maintainer of the stable theme.

The patches from #7 and #8 should be combined - can you prepare a new patch?

rajeshwari10’s picture

Assigned: Unassigned » rajeshwari10
Status: Needs work » Needs review
FileSize
2.41 KB

Combined #7 and #8 patch.

Thanks!!

jo.st’s picture

Thanks for looking at this, great to see this moving forward!

andrewmacpherson’s picture

Looks good! The patch from #13 fixes the correct templates, and produces the expected markup with the heading ID attributes restored, and the aria-labelledby references now work as expected.

For testing, I used the latest versions of Firefox and NVDA screenreader on Windows 7. I enabled the Stark theme, which uses the templates from the system module.

NVDA provides a tool to browse ARIA landmark roles. Here are some screenshots of the landmark information before and after the patch from comment #13.

Before the patch, NVDA knows about the landmark roles, but they don't have distinct labels. There are 4 on the page, but all are simply listed as "navigation".

screenshot of NVDA landmarks window before the patch shows unlabelled landmarks

After the patch, NVDA reports the landmarks with their associated labels. The 4 navigation landmarks each have a different label: Main navigation, User Account Menu, Breadcrumb, and Footer menu.

screenshot of NVDA landmarks window after the patch shows landmarks with labels

Note that both of these screenshots show some other un-labelled landmark regions: banner, main, complementary. This is expected, as these landmarks don't have any aria-labbelledby attributes. This issue is just about fixing the broken ID references for the navigation landmarks which do have aria-labelledby attributes.

I also tested these with the latest ChromeVox screen reader, and it's working fine there too.

Good work! This is a nice win for screen reader / browser combinations which support this feature.

star-szr’s picture

Assigned: rajeshwari10 » star-szr

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 13: 2723961-13.patch, failed testing.

rajeshwari10’s picture

@cottser,

The patch #13 paased in php 5.6 mysql 5.5

Please review.

Thanks!!

andrewmacpherson’s picture

Status: Needs work » Reviewed & tested by the community

Tests are green again, restoring RTBC.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 13: 2723961-13.patch, failed testing.

pashupathi nath gajawada’s picture

Status: Needs work » Needs review
FileSize
2.42 KB

HI @cottser,

Can you please find the update patch,

Thanks,

andrewmacpherson’s picture

Re #21: This patch is a regression from the patch in #13.

I've attached an interdiff to show what changed between #13 and #21...

  1. The breadcrumb navigation landmark no longer gets a label, because the ID referenced by aria-labelledby is not found. This is the very problem we are trying to fix in this issue. Here is a screenshot of the landmark regions list from NVDA screen reader, after applying the patch from #21. There are 4 navigation landmarks, but only 3 have labels.

    screenshot of NVDA landmarks window after patch 21 shows 3 navigation landmarks with labels, and one navigation landmark without a label

    Compare this with the earlier screenshot (in comment #15) which shows that the breadcrumb landmark label was fixed by patch #13.

  2. The patch in #21 also introduces some whitespace around the dot in title_attributes . setAttribute, which we don't seem to use for any other twig variables.

The patch in #13 was previously RTBC, and previously all test were passing. We get intermittent test failures, unrelated to the changes in the patch. (I don't really understand why, but it usually involves the tests for the hook_update_N mechanism. It varies from day to day).

I've queued another test for the patch in #13.

andrewmacpherson’s picture

Another thing to note. The screenshots I included use the Stark theme, which demonstrates that the templates from system.module have been fixed.

I have also been testing this manually with the Stable theme, which we are also fixing. Although it is a "hidden" theme which cannot be enabled via admin/appearance, it can be enabled via drush config-edit system.theme. I'm happy that the patch from comment #13 fixes the stable theme templates.

The last submitted patch, 13: 2723961-13.patch, failed testing.

andrewmacpherson’s picture

andrewmacpherson’s picture

Status: Needs review » Reviewed & tested by the community

The tests are currently green :-)

Restoring RTBC for the patch in comment #13 (not the patch from #21)

pashupathi nath gajawada’s picture

For the patch provided in #21,
Even the id is different.

  • Cottser committed 551dcc0 on 8.2.x
    Issue #2723961 by jo.st, rajeshwari10, andrewmacpherson: Broken aria-...
star-szr’s picture

Version: 8.1.x-dev » 8.2.x-dev
Component: system.module » markup
Assigned: star-szr » Unassigned
Status: Reviewed & tested by the community » Fixed

Committing to 8.2.x only for now since it's a markup change. (https://www.drupal.org/core/d8-allowed-changes#minor)

Committed 551dcc0 and pushed to 8.2.x. Thanks!

pashupathi nath gajawada’s picture

Hi @Cottser ,

Thanks for commiting the patch.
But I was not credited for this issue.May I know the reason why?

Thanks,

star-szr’s picture

@pashupathi nath gajawada:

In short I don't think #21 moved the issue forward and that's what I usually have in mind when determining who should get credit: did this person move the issue forward? Unfortunately I don't think your comments/patch here moved the issue forward so I made the decision not to give you an issue credit. Sometimes we'll give leeway when we can see someone is really trying but I didn't get that impression here based on what I can see. We also try not to enable those who might try to game the issue credit system. In more detail:

  1. After looking at the patch both @andrewmacpherson and myself could only see things being broken, not fixed. Both coding standards and functionality.
  2. There was no explanation given for the changes. This makes it really hard to tell what your intention was in uploading that patch. I understand language can be a barrier but any attempted explanation is better than nothing.

For the above reasons your patch and comment could be interpreted as an attempt to get an issue credit with little to no effort, similar to re-uploading a patch for no reason. I sincerely hope that's not the case here and I also hope that if you're just trying to learn you can continue to do so in other issues. A few lessons you might learn from this issue:

  1. Always write a comment to summarize what your patch does and/or what it's changing.
  2. Get in the habit of uploading interdiffs so that others can easily see what you are changing (@andrewmacpherson helpfully generated one in #22).
  3. Test the code yourself whenever possible, the issue summary of this issue describes how to test it.
star-szr’s picture

@pashupathi nath gajawada I just went and looked at some of the other issues you've worked on recently and your habits there seem to be better than what is shown here. So please continue to do what you've been doing in the other issues where you're describing the changes you're incorporating. Thanks!

pashupathi nath gajawada’s picture

I'm sorry for that @cottser,

That was not my intention.

Sure and thanks for your advice's, I would make sure I would follow the 3 steps which you have suggested while posting.

Thanks,

Status: Fixed » Closed (fixed)

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