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.
| Comment | File | Size | Author |
|---|
Issue fork drupal-3085781
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:
- 3085781-aria-pressed-attribute-isnt
changes, plain diff MR !11337
Comments
Comment #2
claudiu.cristeaPorted patch for tour.
Comment #3
andrewmacpherson commentedThanks claudiu
Comment #4
lauriiiIt 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! ✌️
Comment #6
davps commentedHere is a test that proves the bug.
Comment #7
davps commentedHere's a patch that proves the bug is fixed.
Comment #8
davps commentedSorry for the wrong comment number in the names of the patches, my mistake :(
Comment #9
davps commentedUpdated patches
Comment #11
bnjmnmThe 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.
Comment #14
bnjmnmUpdated because FunctionalJavascript tests now require specifying $defaultTheme.
Comment #15
lendudeJust some nits
these should use assertEquals (and then the arguments need to be swapped around)
In core we don't use
self::here but$this->Comment #16
davps commentedPatch contains fixes according to #14 and #15 comments
Comment #18
andrewmacpherson commentedRe. #11:
This might be scope creep. The top-level buttons which control the visibility of trays shouldn't be using
aria-pressedat all. Those should be usearia-expandedinstead, and there's already another issue for that. See #3090120: Improve accessibility semantics for Toolbar buttons with trays.Comment #19
tanubansal commentedCan someone add a patch for 9.1?
Comment #20
andrewmacpherson commented@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.
Comment #21
tanubansal commentedThanks @andrewmacpherson. I have tried with "add test/ retest" link mentioned in #16 and executed for Drupal 9.1 but it has failed
Comment #22
anu.a_95 commentedComment #23
Kumar Kundan commentedComment #24
abhisekmazumdarTried to fix the failed test cases. Thank You
Comment #25
anu.a_95 commentedComment #26
Kumar Kundan commentedComment #27
anu.a_95 commentedApplied patch #26 successfully
"aria-pressed" attribute is updated correctly after applying the patch

Before patch
aria-pressed attribute is false for the selected "Admin" button before applying the patch
After patch
aria-pressed attribute is true for the selected "Admin" button after applying the patch
Comment #28
anu.a_95 commentedComment #30
Kumar Kundan commentedRerun the last patch #26 & now phpunit seems to be happy with it. Resetting to needs review.
Comment #36
needs-review-queue-bot commentedThe 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.
Comment #37
kunalgautam commentedPatch for Drupal version 10.1.x
Comment #38
nikhil_110 commentedApplied patch #37 successfully
Comment #39
sonam.chaturvedi commentedVerified 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
Comment #40
bnjmnmLooks 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:
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.
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.
Comment #41
mgiffordMarking this for https://www.w3.org/WAI/WCAG21/Understanding/name-role-value
Also including this reference.
https://www.accessibility-developer-guide.com/examples/sensible-aria-usa...
Comment #44
kentr commentedRemoved tag Drupal 9 compatibility as D9 is EOL.
Comment #46
kentr commentedI created an MR against
11.xwith patch #37 and the suggestions from #40.Comment #47
smustgrave commentedHiding patches as the fix is in an MR.
Shows the test coverage
Summary appears to match the fix of using attr
Believe this one is good
Comment #51
nod_Committed and pushed 2f17d640524 to 11.x and dd94411ba01 to 11.1.x and 21bc1da3e70 to 10.5.x. Thanks!