Spin-off from #3066954: Admin toolbar not usable with latest versions of JAWS due to mis-use of aria-owns.
Also noted in #3012027: Decouple tour triggering from the toolbar.

Problem/Motivation

Most of the buttons in toolbar module have an aria-pressed attribute, initialized to false. When pressing them, the state of the UI changes but the value of aria-pressed doesn't get updated. Instead of changing between true and false to reflect the UI, it is always false. Assistive technology therefore always reports these buttons as "off" or "not pressed".

Affected buttons: toolbar buttons which reveal trays, and the tour module button.
Note: the edit button behaves correctly!

Proposed resolution

Make the aria-pressed property actually work.

It may be to do with using jQuery.prop() when we should be using jQuery.attr(). The ARIA attributes are not properties as defined in HTMLElement interfaces.

Remaining tasks

Patch.
Tests - can watch this with FunctionalJavascript test, simulate clicks.

User interface changes

No visual design changes. Corrects faulty handling of a dynamic ARIA state.

API changes

None.

Issue fork drupal-3085781

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.

claudiu.cristea’s picture

Status: Active » Needs review
StatusFileSize
new1012 bytes

Ported patch for tour.

andrewmacpherson’s picture

Thanks claudiu

lauriii’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

It would be awesome if we could have test coverage to prove this is broken and fixed! 🙂

Edit: Just noticed it was mentioned as a remaining task in the issue summary! ✌️

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.

davps’s picture

Here is a test that proves the bug.

davps’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new2.9 KB

Here's a patch that proves the bug is fixed.

davps’s picture

Sorry for the wrong comment number in the names of the patches, my mistake :(

davps’s picture

StatusFileSize
new1.8 KB
new2.92 KB

Updated patches

The last submitted patch, 9: aria_pressed_attribute-test-3085781-9.patch, failed testing. View results

bnjmnm’s picture

StatusFileSize
new1.38 KB
new3.21 KB
new6 KB

The prior patches only covered the tour button, this patch expands to cover the other toolbar buttons (as far as I can tell), and adds a test for toggling the "manage" tray, which is isolated in the test-only patch.

The last submitted patch, 11: 3085781-11-test-only-FAIL.patch, failed testing. View results

Status: Needs review » Needs work

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

bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new539 bytes
new6.08 KB

Updated because FunctionalJavascript tests now require specifying $defaultTheme.

lendude’s picture

Just some nits

  1. +++ b/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php
    @@ -42,10 +42,15 @@ public function testToolbarToggling() {
    +    $this->assertEqual($manage_link->getAttribute('aria-pressed'), 'true');
    ...
    +    $this->assertEqual($manage_link->getAttribute('aria-pressed'), 'false');
    ...
    +    $this->assertEqual($manage_link->getAttribute('aria-pressed'), 'true');
    

    these should use assertEquals (and then the arguments need to be swapped around)

  2. +++ b/core/modules/tour/tests/src/FunctionalJavascript/TourJavascriptTest.php
    @@ -0,0 +1,58 @@
    +    self::assertSame('false', $tour_toolbar_button->getAttribute('aria-pressed'), 'The "Tour" button in the toolbar is not yet pressed.');
    +    self::assertFalse($tour_toolbar_button->hasClass('is-active'), 'The "Tour" button in the toolbar is not yet marked as active.');
    ...
    +    self::assertSame('true', $tour_toolbar_button->getAttribute('aria-pressed'), 'The "Tour" button in the toolbar is pressed.');
    +    self::assertTrue($tour_toolbar_button->hasClass('is-active'), 'The "Tour" button in the toolbar is marked as active.');
    

    In core we don't use self:: here but $this->

davps’s picture

StatusFileSize
new6.36 KB

Patch contains fixes according to #14 and #15 comments

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.

andrewmacpherson’s picture

Re. #11:

The prior patches only covered the tour button, this patch expands to cover the other toolbar buttons

This might be scope creep. The top-level buttons which control the visibility of trays shouldn't be using aria-pressed at all. Those should be usearia-expanded instead, and there's already another issue for that. See #3090120: Improve accessibility semantics for Toolbar buttons with trays.

tanubansal’s picture

Can someone add a patch for 9.1?

andrewmacpherson’s picture

@tanubansal - Do you see the "add test / retest" link next to the patches on each issue? You can use those to (re-)test any patch against multiple environments. Normally the tests only get run for the version specified in the issue metadata, but it's useful to check if an older patch still applies to a newer version of core.

I've queued some tests of patch #16 against Drupal 9.1, and we'll see the result next to the patch in that issue.

tanubansal’s picture

StatusFileSize
new340.53 KB

Thanks @andrewmacpherson. I have tried with "add test/ retest" link mentioned in #16 and executed for Drupal 9.1 but it has failed

anu.a_95’s picture

Status: Needs review » Needs work
Issue tags: +Drupal 9 compatibility
Kumar Kundan’s picture

StatusFileSize
new6.15 KB
new3.73 KB
abhisekmazumdar’s picture

Status: Needs work » Needs review
StatusFileSize
new970 bytes
new6.12 KB

Tried to fix the failed test cases. Thank You

anu.a_95’s picture

Status: Needs review » Needs work
Kumar Kundan’s picture

Status: Needs work » Needs review
StatusFileSize
new6.13 KB
new516 bytes
anu.a_95’s picture

StatusFileSize
new125.71 KB
new121.7 KB

Applied patch #26 successfully

"aria-pressed" attribute is updated correctly after applying the patch

Before patch

Before
aria-pressed attribute is false for the selected "Admin" button before applying the patch




After patch
After
aria-pressed attribute is true for the selected "Admin" button after applying the patch

anu.a_95’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 26: 3085781-26.patch, failed testing. View results

Kumar Kundan’s picture

Status: Needs work » Needs review

Rerun the last patch #26 & now phpunit seems to be happy with it. Resetting to needs review.

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.

kunalgautam’s picture

StatusFileSize
new2.32 KB

Patch for Drupal version 10.1.x

nikhil_110’s picture

Status: Needs work » Needs review
StatusFileSize
new15.58 MB

Applied patch #37 successfully

sonam.chaturvedi’s picture

StatusFileSize
new213.77 KB
new1.06 MB

Verified and tested patch #37 on 10.1.x-dev. Patch applied cleanly.

Test Result:
"aria-pressed" attribute of toolbar buttons is updated correctly. "aria-pressed" attribute is set to "true" when button is pressed else it is "false".

Please find attached before and after patch screenshots.
RTBC

bnjmnm’s picture

Status: Needs review » Needs work

Looks like we're good on screenshots/videos and don't need any more of them in the issue.
I spotted some things in the test:

  1. +++ b/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php
    @@ -42,10 +42,16 @@ public function testToolbarToggling() {
    +    $manage_link->getAttribute('aria-pressed');
    +    $this->assertEquals('true', $manage_link->getAttribute('aria-pressed'));
    

    Why is this getting the attribute without assigning it to a varianble and then getting it again in the assertEquals(). Seeme like the one line is that is needed.

  2. +++ b/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php
    @@ -42,10 +42,16 @@ public function testToolbarToggling() {
    -    $page->clickLink('Manage');
    +    $manage_link->click();
    +    $this->assertEquals('false', $manage_link->getAttribute('aria-pressed'));
         $this->assertFalse($content->isVisible(), 'Toolbar tray is closed after clicking the "Manage" link.');
    -    $page->clickLink('Manage');
    +    $manage_link->click();
    +    $this->assertEquals('true', $manage_link->getAttribute('aria-pressed'));
    

    All of the checks for aria-pressed should have some sort of waitFor incorporated into it. In some instances a test may check for the attribute value before the JS has completed the change.

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.

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

kentr’s picture

Assigned: Unassigned » kentr
Issue tags: -Drupal 9 compatibility

Removed tag Drupal 9 compatibility as D9 is EOL.

kentr’s picture

Assigned: kentr » Unassigned
Status: Needs work » Needs review

I created an MR against 11.x with patch #37 and the suggestions from #40.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Hiding patches as the fix is in an MR.

1) Drupal\Tests\toolbar\FunctionalJavascript\ToolbarIntegrationTest::testToolbarToggling
Failed asserting that false is true.
/builds/issue/drupal-3085781/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php:115
/builds/issue/drupal-3085781/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php:51
FAILURES!
Tests: 2, Assertions: 17, Failures: 1.

Shows the test coverage

Summary appears to match the fix of using attr

Believe this one is good

  • nod_ committed 21bc1da3 on 10.5.x
    Issue #3085781 by davps, bnjmnm, kentr, Kumar Kundan, abhisekmazumdar,...

  • nod_ committed dd94411b on 11.1.x
    Issue #3085781 by davps, bnjmnm, kentr, Kumar Kundan, abhisekmazumdar,...

  • nod_ committed 2f17d640 on 11.x
    Issue #3085781 by davps, bnjmnm, kentr, Kumar Kundan, abhisekmazumdar,...
nod_’s picture

Version: 11.x-dev » 10.5.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 2f17d640524 to 11.x and dd94411ba01 to 11.1.x and 21bc1da3e70 to 10.5.x. Thanks!

Status: Fixed » Closed (fixed)

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