Problem/Motivation
WAI-ARIA 1.1 introduces a useful new property: aria-current.
One place where we can use this is on pagination links. Currently, the pager styles in Seven and Bartik have a visual indication of the current page, together with a .visually-hidden span to say it is the current page (which screen readers announce). It's working fine at the moment, but we can modernize this.
The idea behind the aria-current="page"
is to indicate this in a machine-readable way that can be conveyed to assistive technology though the platform-level accessibility APIs. The advantage is that screen readers, etc., can present the information in a way that is more consistent with native applications on host platform, such as:
- Announce it with a platform-localized string (from assistive tech on the host OS), instead of an author-localized string (from Drupal translations).
- Decide how/when to announce the fact, possibly based on user preferences in the host OS or assistive tech (e.g. screen reader verbosity prefs).
Demo page: http://design-patterns.tink.uk/aria-current/ (includes test results for various devices)
Proposed resolution
aria-current="page"
to the current page link in the pager.
Important: this should go on the <a>
element, not the <li>
wrapper.<span class="visually-hidden">Page: </span>
like all the other numbered links.
From #94 we will try and use theme_preprocess_page() to add this variable.
Remaining tasks
- Assess: is there sufficient support for
aria-current="page"
across various browsers, assistive tech, and OS? Ask around the wider accessibility community. In particular, we'd like to know where it isn't supported yet, to assess the regression risk.- DONE: support looks good in general (comment #3). iOS + macOS Safari work, and there are several browser/screen-reader combinations working on Windows.
- DONE: ChromeVox + desktop Chrome Browser. Not currently working, see comment #7.
- TODO: monitor Android Talkback, not working yet (comment #6).
- TODO: monitor support with MS Edge + JAWS. Watch this bug report: No support for aria-current in Edge.
- DONE: Monitor support for MS Edge + Narrator. WAI-ARIA 1.1 is support is "in development" according to MS Edge Platform Status. See comment #57
- DONE: Test in ChromeVox on ChromeOS. See comment #7 and #50
- DONE: test macOS Voiceover with Chrome. See comment #50
- Assess: does this impact on a template in the Stable and Classy themes?
- Write a patch.
- Update using hook vs twig templates
- Tests
Sign-offs needed
IMPORTANT: Possible regression risk - get sign-off from an accessibility maintainer, @andrewmacpherson or @mgifford.
Don't commit this until we're confident there's enough support across various OS, browsers, and assistive tech. It can wait until the time is right, and go in any minor release.
User interface changes
- Improved semantics for assisitive technology. Replace an invisible text span with machine readable attribute.
- No changes to visual design, or CSS.
API changes
None.
Data model changes
None.
Commit Credits needed
@RachelOlivero - researched Android Talkback support, comments #6 and #38.
Comment | File | Size | Author |
---|---|---|---|
#109 | 2952488-109.patch | 2.65 KB | andypost |
#109 | interdiff.txt | 799 bytes | andypost |
#108 | interdiff.txt | 2.34 KB | andypost |
#104 | 2952488-104.patch | 1.98 KB | smustgrave |
#104 | diff-102-104.txt | 850 bytes | smustgrave |
Comments
Comment #2
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedAccording to Leonie Watson's blog, VoiceOver and Jaws 18 support it. See comments following Using the aria-current attribute.
NVDA supports it from v2017.2 (change notes).
Comment #3
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedAsked on the web-a11y Slack team. Scott O'Hara told me about the browser support table on Leonie Watson's demo page: http://design-patterns.tink.uk/aria-current/
It looks broadly supported by screen readers. The notable gaps are the MS Edge browser with JAWS (bug report) or Narrator, and Android Talkback.
I think this shows a good enough level of support for aria-current, that we can proceed with making a patch. When we get near to 8.6.0-alpha1, we can decide if we want to go ahead with it, or postpone.
Comment #4
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedComment #5
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedThere's an open bug report for aria-current with MS Edge + JAWS: No support for aria-current in Edge. I've subscribed to it on GitHub.
Leonie Watson's demo page reports that MS Edge + Narrator doesn't support it yet. I can't find a specific bug report about aria-current, but the MS Edge Platform Status page shows WAI-ARIA 1.1 marked as "in development".
Comment #6
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedaria-current doesn't work with Talkback on Android:
@rolivero_nfb deserves a commit credit here.
Comment #7
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedTested the demo page with ChromeVox + Chrome 65.0 on Kubuntu 17.10 Linux. Not working. TBH I don't really care about the ChromeVox extension on Windows, Mac, or Linux - it's not really a platform-level integration with the OS.
The version of ChromeVox which comes with ChromeOS is apparently different. I think that's worth monitoring at least, because it counts as platform-level assistive tech there.
I think we have a good enough idea about support for aria-current now. It's good enough that I don't think it's a blocker for this issue. We can go ahead and write a patch.
Comment #8
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedComment #9
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedComment #10
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer commentedStarting a patch could be a good mentored sprint activity for nashville. The markup changes themselves are simple enough.
Comment #11
jmickelaStarting to work on this at the Mentored Sprint.
Comment #12
Winn CreditAttribution: Winn commentedWorking on this, as part of Nashville2018 Sprint
Comment #13
jmickelaHere's a patch that resolves this issue.
I left the visually hidden span in place to cover people using devices that don't support aria-current.
Comment #14
jmickelaComment #15
jgloverattronedotcom CreditAttribution: jgloverattronedotcom commentedWe are reviewing the patch from jmickela now.
Comment #16
dcgoodwin CreditAttribution: dcgoodwin commentedReviewing 2952488-13.patch at Nashville2018 Sprint
Comment #17
jgloverattronedotcom CreditAttribution: jgloverattronedotcom commentedWe reviewed patch 2952488-13 and found that it worked correctly. See attached screenshots showing the before and after.
Comment #18
jgloverattronedotcom CreditAttribution: jgloverattronedotcom commentedComment #19
jgloverattronedotcom CreditAttribution: jgloverattronedotcom commentedComment #20
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer commentedNice to see this moving, thanks @jmickela, @jgloverattronedotcom, @dcgoodwin, @winn.
patch #13 just addresses the first point in the proposed resolution: adding the aria-current="page" attribute. @jmickela said:
Please go ahead and get that part into the patch! The intention is to replace the old method with the new one - having both could be too verbose. There's no hurry to commit this new feature, in fact I prefer we hold back from committing it until we know that aria-current is supported by enough assistive tech. But we can move the patch forward in the meantime, and we'll need that for manual testing with screen readers anyway.
The markup screenshots in dev tools confirm the attribute is being added to the correct element. It's the
<a>
, not thewrapper. Note, there's no need for a screenshot of the git diff, we've got the patch file itself.
Updated the issue summary to make it clear that accessibility maintainers should sign this off. Don't want to release this too early.
Comment #21
dcgoodwin CreditAttribution: dcgoodwin commentedHere is a patch that includes the changes from the patch by @jmickela and also removes the span tag in core/includes/pager.inc
Comment #22
dcgoodwin CreditAttribution: dcgoodwin commentedComment #23
dcgoodwin CreditAttribution: dcgoodwin commentedMoving back to 'needs work' after failed unit test
Comment #24
dcgoodwin CreditAttribution: dcgoodwin commentedEdit: Fixed issues with my previous patch
Here is a patch that includes the changes from the patch by @jmickela and also removes the span tag in core/includes/pager.inc
Comment #25
dcgoodwin CreditAttribution: dcgoodwin commentedFix corrupt patch in previous comment.
Comment #26
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer commentedReview of patch #25:
Ah, I didn't consider this properly. All links in the pager have a visually-hidden span, most just contain the word "page". We'll want to keep that - it's just the visually-hidden text which says "current" that we want to remove.
Looking at the test failures, this is what caused some of them. ("The link Page 2 was not found on the page.")
I think what we actually want here is more like:
Comment #28
sim_1Added back in hidden 'Page' text per comment #26.
I also reverted a change that seems to have happened in patch #25 where the attribute was being set in a different part of the code that was checking if there should be an ellipsis.
A question I have: I understand that the scope of this patch is specifically to apply the aria attribute to pagination links. Pagination generated by the views-mini-pager.twig (e.g. used on the Recent Log Messages page) isn't getting this update. Do we want to extend it to that twig file?
Comment #29
izus CreditAttribution: izus commentedi triggered retesting for patch in #28 and it seems ok
s changing the issue status
Comment #30
kalyansamanta CreditAttribution: kalyansamanta at Asentech LLC commentedComment #32
heykarthikwithu@kalyansamanta their is no difference for the patch #28 and #30.. They are identical.. why are you posting an identical patch?
I came across similar thing done by you in different ticket - https://www.drupal.org/project/drupal/issues/2920395 #24
Comment #33
alexpottI've removed issue credit for @kalyansamanta - they've contacted me and appear to be aware of their mistake.
Comment #34
Krzysztof DomańskiUnrelated test failure. Back to Needs review.
Comment #35
volkswagenchickTagging for upcoming contribution days.
Comment #37
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer commentedComment #38
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer commentedCredited @RachelOlivero for #6, useful manual testing feedback via Slack #accessibility channel.
I think they have changed their d.o username, but I found a couple of other accessibility issues they filed, and it's the right person I'm sure. They've been a fairly frequent chatter in the accessibility Slack channel. Their previous username was @rachel_nfb, where "nfb" stood for national federation of the blind. This organisation is still on their user profile.
Comment #39
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer commentedComment #40
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer commentedAdding an earlier issue for historical background, which explains how we arrived at the current markup.
aria-current
wasn't available back then.Comment #41
tim.plunkettFixing tags.
Comment #43
tatarbjComment #44
AaronMcHaleComment #45
pau1_m CreditAttribution: pau1_m as a volunteer and commentedRedoing patch for latest Drupal version.
Comment #46
pau1_m CreditAttribution: pau1_m as a volunteer and commentedUpdating dir in patch
Comment #47
subhojit777Comment #48
mgiffordLooks good to me. I tested it on the home page (and the admin pages). Looks fine. Here are some screenshots for fun.
So the re-rolled patch works. Any reason not to mark this RTBC?
Comment #49
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer commentedWe should check browser support first. There are some still in the TODO list.
Comment #50
sim_1I tested this patch on a Chomebook with ChromeVox and on MacOS's Chrome with VoiceOver. They both work as expected and announce when a page is the current page.
I've updated the TODOs marking those two tests as done.
Comment #51
idebr CreditAttribution: idebr at iO commentedUpdated patch after #3067584: Pager template renders attributes that do not exist was committed:
use
statementnew Attribute()
lineComment #53
mradcliffeTagging for amsterdam 2019.
Comment #54
pminfI have some expertise in a11y and will test this on windows with narrator.
Comment #55
pminfHad to reroll the patch from #51 against 8.9.x.
Comment #56
Chi CreditAttribution: Chi commentedWhy does this issue consider only pagination links? Can we extend it to support menus and tabs?
Comment #57
pminf@Chi: You are right but I think active menu links should be handled in a separate issue.
Anyway, I've tested the pagination on Windows 10 Pro (10.0.17134) with Narrator. The software reads
This output is based on the value of the title attribute and not on the aria-current attribute. I've tested this by removing/changing the title attribute. So unfortunately the proposed solution does not work with Edge and Narrator. BUT, as long we have the correct title according to the aria-current attribute, it's fine. The title attribute serves as a fallback. Does anyone disagree?
Comment #58
pminfFixed link to wrong comment in issue summary.
Comment #59
realityloop@pminf can you possibly add an interdiff? https://www.drupal.org/documentation/git/interdiff
I also agree that menu links should be addressed in another issue, perhaps you'd like to create that @Chi ?
Comment #60
Chi CreditAttribution: Chi commented@realityloop
I've just slightly changed the scope of #3089689: Use aria-current="page" to indicate active link in menus and reopened it.
Comment #61
pminf@realityloop As I learned today, it is not possible to make an interdiff on a reroll. But here is a screenshot of the file compare between patch #51 and #55.
Comment #62
realityloop@pminf well, I leant something.. thanks.
Comment #63
lauriiiI'm not sure we should be making this an attributes object since this could be a BC break.
This change should be done also in core, Stable and Claro.
Comment #64
boulaffasae CreditAttribution: boulaffasae as a volunteer and at Fullwave commentedHello @laurii, Here's a fix for #63
W3C Recommendation:
Another question about core/themes/claro/templates/views/views-mini-pager.html.twig file. Should we add aria-current="page" to the current page li wrapper ?
Comment #66
pminfFailed because of a ci error. Let's try again.
Comment #68
alisonFWIW, the patch works great on core 8.8.8, for my "full pager" on a "page" view display!
Thank you so much!
Comment #69
JayKandariComment #71
michaellenahan CreditAttribution: michaellenahan at Hubert Burda Media commentedRemoving Europe2020 tag, since this issue was not worked on at Drupalcon Europe 2020.
Comment #72
michaellenahan CreditAttribution: michaellenahan at Hubert Burda Media commentedComment #73
michaellenahan CreditAttribution: michaellenahan at Hubert Burda Media commentedComment #74
michaellenahan CreditAttribution: michaellenahan at Hubert Burda Media commentedComment #75
Abhijith S CreditAttribution: Abhijith S as a volunteer and at Zyxware Technologies commentedApplied patch #64 on 9.2.x and it works fine. Attaching screenshots below.
Content section:
Admin section:
Comment #76
alisonOn 8.9.13:
Patch has been working great for us since August 2020 -- I just added it to another site last week, it worked great!
I realize more work might be needed to get this committed, BUT:
⭐ Does anyone have a feel for whether maintainers are on board with the concept? (i.e. would I be correct to say to colleagues that this thing will likely be committed eventually, or?)
Comment #79
pminfLast tests failed. Working on this during ContributionWeekend2022.
Comment #80
pminf1) Changed twig so that aria-current is not set at all if page is not the current one, because the attributes with no value is useless (both apply the aria-current default value false).
2) Changed file hash to pass test if pager.html.twig files of related themes are identical.
Comment #81
pminfCorrected some wrong indentations in patch #80.
Comment #82
Asha Nair CreditAttribution: Asha Nair commentedApplied patch #81 successfully. Works fine, sharing screenshots.
Comment #83
baronePatch #81 applied successfully
Before patch
After patch
However, after checking the before and after with an actual screen reader, i believe this is not the expected behavior for pager links. (excuse the cell phone video but i could not get the screen reader and screen recorder together).
Before the patching the screen reader indicates that this is the current page:
https://www.drupal.org/files/issues/2022-02-14/pagination-afterpatch.mp4
And after the patch it doesn't anymore.
https://www.drupal.org/files/issues/2022-02-14/pagination-before-patch.mp4
The WAI-ARIA documentation https://www.w3.org/TR/wai-aria-1.1/#aria-currentstates that "aria-current="page" can be used in a navigation tree to indicate which page is currently displayed, while aria-selected="true" indicates which page will be displayed if the user activates the treeitem."
Isn't this the case where to use aria-current=true instead of aria-current=page?
More info at: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attribut...
Comment #84
Manibharathi ER CreditAttribution: Manibharathi ER at UniMity Solutions Pvt Limited for Drupal India Association commentedThe patch works great, the aria-current=page added in pagination links.
Before Patch,
After Patch
Comment #86
Shubham Sharma 77 CreditAttribution: Shubham Sharma 77 at Material for Drupal India Association commentedApplied patch #81 applied successfully in drupal-9.5.x-dev. We can move this ticket to RTBC.
Thanks for the patch
For ref sharing screenshots...
Comment #87
Meeni_Dhobale CreditAttribution: Meeni_Dhobale at QED42 for Drupal India Association commentedThe changes mentioned in #81 patch is applied successfully on branch 9.5.x-dev.
Sharing screenshot for reference:
Before patch apply:
After patch apply:
Can move this issue in RTBC
Comment #88
smustgrave CreditAttribution: smustgrave at Mobomo commentedTesting patch #81
Verified issue without patch
Verified issue is fixed with patch
Comment #89
quietone CreditAttribution: quietone at PreviousNext commentedStarting at the Issue Summary I see there are still tasks to do in the Issue Summary. The Issue Summary states this needs signoff from an accessibility maintainer and I do not see that in the comments. Setting back to NW. Ah, yes it is tagged for 'needs accessibility review'. That needs to happen before a committer looks at this.
Comment #83 seems rather thorough and concludes the patch is not working as expected. There has been no response addressing the points in that comment. Can someone respond to that?
I appears that #86 and #87 are creating screenshot on the same patch which already has screenshots, therefor removing credit.
This patch being tests is in #81 and from 9.4.x, this is a feature request, so let's get a patch that applies to 9.5 and 10. Also, that patch is failing.
A reminder to only upload new screenshots if they are none on the latest patch or you screenshots are indeed adding new information.
Comment #91
mgiffordI am in favour of adding this patch. This does very much seem to be a best practice we should be adopting.
https://www.accessibility-developer-guide.com/examples/sensible-aria-usa...
https://design-system.w3.org/components/pagination.html
https://tink.uk/using-the-aria-current-attribute/
https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attribut...
https://getbootstrap.com/docs/4.0/components/breadcrumb/
https://a11y-guidelines.orange.com/en/articles/using-aria-current-attrib...
Comment #92
mgiffordRemoving the accessibility maintainer review.
Comment #93
smustgrave CreditAttribution: smustgrave at Mobomo commentedOh man horrible review on my part.
Rerolled for D10 addressing the other themes that were left out.
I don't think the olivero one is needed but wanted some feedback.
Also if this is the correct approach are we going to need tests per theme?
Comment #94
DuaelFr#63 asked this processing to be removed from
template_preprocess_pager()
as it would be a BC break. BC Layer has been removed in #3087517: Remove BC layer for Pager service so I suppose we could now just make this in this function and that would apply on all themes that didn't remove theitem.attributes
output from their own templates (including contrib themes).What do you think about it?
Comment #95
smustgrave CreditAttribution: smustgrave at Mobomo commentedI think that would be the best solution.
Also thing we should add simple test assertion that the attribute appears.
Comment #96
smustgrave CreditAttribution: smustgrave at Mobomo commentedNo interdiff as this is a new approach
Comment #98
pradipmodh13 CreditAttribution: pradipmodh13 at Material for Drupal India Association commentedApplied patch #96 applied successfully in drupal-10.1.x-dev.
We can move this ticket to RTBC.
Thanks for the patch.
Attached screenshot.
Comment #99
larowlanLooking good, one obvervation and a change required for the test changes in my book
At this point $item['pages'][$i]['attributes'] is an Attribute object, so in theory we could use ->setAttribute here instead of ArrayAccess, but not sure it matters that much
The test method is named testQuantityNotSet but now the quantity is set.
Is there another test method we can use here instead of modifying the intent of this test? Or should we just add another method? This is a unit test so it should be cheap
Comment #100
mgiffordTagging for https://www.w3.org/WAI/WCAG21/Understanding/name-role-value
Comment #102
smustgrave CreditAttribution: smustgrave at Mobomo commentedAddressed points in #99
Comment #103
needs-review-queue-bot CreditAttribution: needs-review-queue-bot as a volunteer commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #104
smustgrave CreditAttribution: smustgrave at Mobomo commentedComment #105
andypostit could use
new TranslatableMarkup
instead oft()
Comment #106
andypostPlease use
\Drupal\Core\StringTranslation\TranslatableMarkup::getUntranslatedString()
instead of testing string translationComment #107
smustgrave CreditAttribution: smustgrave at Mobomo commented@andypost not sure I follow #106?
Comment #108
andypostI mean that)
Comment #109
andypostBit better wording
Comment #110
smustgrave CreditAttribution: smustgrave at Mobomo commentedAh thanks! I'll have to note that.
Since this was a small patch and the change touched each line think I'm good to mark it also.
Comment #112
longwaveBackported to 10.1.x as an accessibility bug fix.
Committed and pushed 38e908395d to 11.x and 2f060c96e5 to 10.1.x. Thanks!
Fixed on commit:
Comment #114
longwaveComment #116
neclimdulLooks like the value used for this attribute is incorrect. Filed a follow up
https://www.drupal.org/project/drupal/issues/3384679