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

  • Add aria-current="page" to the current page link in the pager.
    Important: this should go on the <a> element, not the <li>wrapper.
  • Remove the visually-hidden phrase "current page" from inside the current-page link. Just use<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.

CommentFileSizeAuthor
#109 2952488-109.patch2.65 KBandypost
#109 interdiff.txt799 bytesandypost
#108 2952488-108.patch2.63 KBandypost
#108 interdiff.txt2.34 KBandypost
#104 2952488-104.patch1.98 KBsmustgrave
#104 diff-102-104.txt850 bytessmustgrave
#103 2952488-nr-bot.txt86 bytesneeds-review-queue-bot
#102 2952488-102.patch2 KBsmustgrave
#102 interdiff-96-102.txt1.54 KBsmustgrave
#98 2952488-after-patch.png546.23 KBpradipmodh13
#98 2952488-before-patch.png496.28 KBpradipmodh13
#96 2952488-96.patch1.86 KBsmustgrave
#96 2952488-96-tests-only.patch1.36 KBsmustgrave
#93 2952488-93.patch4.54 KBsmustgrave
#93 interdiff-81-93.txt4.51 KBsmustgrave
#88 after_patch.png639.62 KBsmustgrave
#88 before_patch.png539.69 KBsmustgrave
#87 after-applied.png182.65 KBMeeni_Dhobale
#87 before-applied.png205.45 KBMeeni_Dhobale
#86 Before-patch.png63.86 KBShubham Sharma 77
#86 After-patch.png71.46 KBShubham Sharma 77
#84 After review.PNG20.03 KBManibharathi ER
#84 Before Review.PNG18.6 KBManibharathi ER
#83 pagination-afterpatch.mp425.74 MBbarone
#83 pagination-before-patch.mp422.57 MBbarone
#83 Screenshot from 2022-02-14 07-24-06.png102 KBbarone
#83 3262374-after-patch-81.png184.36 KBbarone
#83 3262374before-patch-81.png184.25 KBbarone
#82 after-patch-81.jpg183.38 KBAsha Nair
#82 before-patch -81.png73.37 KBAsha Nair
#81 2952488-81.patch4.39 KBpminf
#81 interdiff_80-81.txt1.62 KBpminf
#80 interdiff_64-80.txt4.15 KBpminf
#80 2952488-80.patch4.39 KBpminf
#75 2952488_after-64_2.png58.86 KBAbhijith S
#75 2952488_after-64_1.png60.7 KBAbhijith S
#64 interdiff_55-64.txt3.3 KBboulaffasae
#64 2952488-64.patch3.44 KBboulaffasae
#61 interdiff-51-55.JPG119.15 KBpminf
#55 2952488-55.patch1.11 KBpminf
#51 2952488-51.patch1.1 KBidebr
#51 interdiff-46-51.txt862 bytesidebr
#48 FirstLink-CurrentPage.png198.56 KBmgifford
#48 FirstLink-admin-CurrentPage.png120.53 KBmgifford
#48 MiddleLink-CurrentPage.png91.04 KBmgifford
#48 LastLink-CurrentPage.png98.28 KBmgifford
#46 use_aria_current_page_pagination_links-2952488.patch1.42 KBpau1_m
#45 use_aria_current_page_pagination_links-2952488.patch1.39 KBpau1_m
#30 use_aria_current_page_pagination_links-2952488-30.patch1.37 KBkalyansamanta
#28 2952488-27.patch1.38 KBsim_1
#28 interdiff_25_27.txt1.43 KBsim_1
#25 2952488-25.patch1.34 KBdcgoodwin
#24 2952488-24.patch1.43 KBdcgoodwin
#21 2952488-21.patch1.49 KBdcgoodwin
#17 After2.png384.97 KBjgloverattronedotcom
#17 After.png407.84 KBjgloverattronedotcom
#17 Patch.png201.25 KBjgloverattronedotcom
#17 Before.png487.2 KBjgloverattronedotcom
#13 2952488-13.patch773 bytesjmickela
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andrewmacpherson created an issue. See original summary.

andrewmacpherson’s picture

According 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).

andrewmacpherson’s picture

Issue summary: View changes

Asked 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.

andrewmacpherson’s picture

Issue summary: View changes
andrewmacpherson’s picture

Issue summary: View changes

There'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".

andrewmacpherson’s picture

Issue summary: View changes

aria-current doesn't work with Talkback on Android:

  • Leonie Watson's demo page says no with Android Talkback + FireFox, and ad Talkback + Chrome is unknown.
  • I tested with Android 7.0 + Talkback 6.1.0 on an LG-G6, using Chrome 65.0 and Firefox 59.0 browsers. aria-current isn't working with either.
  • @rolivero_nfb also tested Chrome + Talkback, and reported on Slack: "Not supported with Talkback and Chrome. Tested on an S5 and the Pixel."

@rolivero_nfb deserves a commit credit here.

andrewmacpherson’s picture

Issue summary: View changes

Tested 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.

andrewmacpherson’s picture

Issue summary: View changes
andrewmacpherson’s picture

Issue summary: View changes
andrewmacpherson’s picture

Issue tags: +Nashville2018, +Novice

Starting a patch could be a good mentored sprint activity for nashville. The markup changes themselves are simple enough.

jmickela’s picture

Starting to work on this at the Mentored Sprint.

Winn’s picture

Working on this, as part of Nashville2018 Sprint

jmickela’s picture

Here'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.

jmickela’s picture

Status: Active » Needs review
jgloverattronedotcom’s picture

We are reviewing the patch from jmickela now.

dcgoodwin’s picture

Reviewing 2952488-13.patch at Nashville2018 Sprint

jgloverattronedotcom’s picture

FileSize
487.2 KB
201.25 KB
407.84 KB
384.97 KB

We reviewed patch 2952488-13 and found that it worked correctly. See attached screenshots showing the before and after.

Before
Patch
After
After2

jgloverattronedotcom’s picture

Status: Needs review » Reviewed & tested by the community
jgloverattronedotcom’s picture

andrewmacpherson’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work

Nice 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:

I left the visually hidden span in place to cover people using devices that don't support aria-current.

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 the wrapper. 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.

dcgoodwin’s picture

Here is a patch that includes the changes from the patch by @jmickela and also removes the span tag in core/includes/pager.inc

dcgoodwin’s picture

Status: Needs work » Needs review
dcgoodwin’s picture

Status: Needs review » Needs work

Moving back to 'needs work' after failed unit test

dcgoodwin’s picture

Edit: 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

dcgoodwin’s picture

Fix corrupt patch in previous comment.

andrewmacpherson’s picture

Issue summary: View changes
Issue tags: +Nwdug_may18

Review of patch #25:

-            <span class="visually-hidden">
-              {{ current == key ? 'Current page'|t : 'Page'|t }}
-            </span>

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:

            <span class="visually-hidden">
-              {{ current == key ? 'Current page'|t : 'Page'|t }}
+             {{ 'Page'|t }}
            </span>

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

sim_1’s picture

Added 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?

izus’s picture

Status: Needs work » Needs review

i triggered retesting for patch in #28 and it seems ok
s changing the issue status

Status: Needs review » Needs work
heykarthikwithu’s picture

@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

alexpott’s picture

I've removed issue credit for @kalyansamanta - they've contacted me and appear to be aware of their mistake.

Krzysztof Domański’s picture

Status: Needs work » Needs review

Unrelated test failure. Back to Needs review.

volkswagenchick’s picture

Issue tags: +fldc19, +sfdug, +dcnj19

Tagging for upcoming contribution days.

andrewmacpherson’s picture

andrewmacpherson’s picture

Credited @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.

andrewmacpherson’s picture

Issue summary: View changes
andrewmacpherson’s picture

Adding an earlier issue for historical background, which explains how we arrived at the current markup. aria-current wasn't available back then.

tim.plunkett’s picture

Issue tags: -accessibility (duplicate tag), -Nashville2018, -Nwdug_may18, -fldc19, -sfdug, -dcnj19 +Accessibility

Fixing tags.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

tatarbj’s picture

Issue tags: +DrupalCampBelarus2019
AaronMcHale’s picture

Issue tags: +DCScot19
pau1_m’s picture

Redoing patch for latest Drupal version.

pau1_m’s picture

subhojit777’s picture

Issue tags: +#DCD19
mgifford’s picture

Looks 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?

andrewmacpherson’s picture

We should check browser support first. There are some still in the TODO list.

sim_1’s picture

Issue summary: View changes

I 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.

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.

mradcliffe’s picture

Issue tags: +Amsterdam2019

Tagging for amsterdam 2019.

pminf’s picture

I have some expertise in a11y and will test this on windows with narrator.

pminf’s picture

Had to reroll the patch from #51 against 8.9.x.

Chi’s picture

Why does this issue consider only pagination links? Can we extend it to support menus and tabs?

pminf’s picture

Issue summary: View changes

@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

click info "current page"

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?

pminf’s picture

Issue summary: View changes

Fixed link to wrong comment in issue summary.

realityloop’s picture

@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 ?

Chi’s picture

@realityloop
I've just slightly changed the scope of #3089689: Use aria-current="page" to indicate active link in menus and reopened it.

pminf’s picture

FileSize
119.15 KB

@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.

realityloop’s picture

Status: Needs review » Reviewed & tested by the community

@pminf well, I leant something.. thanks.

lauriii’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/includes/pager.inc
    @@ -250,6 +251,8 @@ function template_preprocess_pager(&$variables) {
    +         $items['pages'][$i]['attributes'] = new Attribute();
    

    I'm not sure we should be making this an attributes object since this could be a BC break.

  2. +++ b/core/includes/pager.inc
    --- a/core/themes/classy/templates/navigation/pager.html.twig
    +++ b/core/themes/classy/templates/navigation/pager.html.twig
    
    +++ b/core/themes/classy/templates/navigation/pager.html.twig
    @@ -66,7 +66,7 @@
    -              {{ current == key ? 'Current page'|t : 'Page'|t }}
    +              {{ 'Page'|t }}
    

    This change should be done also in core, Stable and Claro.

boulaffasae’s picture

Hello @laurii, Here's a fix for #63

  1. The aria-current attribute is set in the TWIG template.
          <a aria-current="{{ current == key ? 'page' }}">
        

    W3C Recommendation:

    The aria-current attribute is an enumerated type. [...] If the attribute is not present or its value is an empty string or undefined, the default value of false applies and the aria-current state MUST NOT be exposed by user agents or assistive technologies.

  2. Change are now also in core, Stable and Claro.

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 ?

  {% if items.current %}
    <li class="pager__item pager__item--mini pager__item--current">
      <span class="visually-hidden">
        {{ 'Current page'|t }}
      </span>
      {{ items.current }}
    </li>
  {% endif %}

Status: Needs review » Needs work

The last submitted patch, 64: 2952488-64.patch, failed testing. View results

pminf’s picture

Status: Needs work » Needs review

Failed because of a ci error. Let's try again.

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.

alison’s picture

FWIW, the patch works great on core 8.8.8, for my "full pager" on a "page" view display!

Thank you so much!

JayKandari’s picture

Issue tags: +DIACWAug2020

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.

michaellenahan’s picture

Issue summary: View changes

Removing Europe2020 tag, since this issue was not worked on at Drupalcon Europe 2020.

michaellenahan’s picture

michaellenahan’s picture

michaellenahan’s picture

Issue summary: View changes
Abhijith S’s picture

Applied patch #64 on 9.2.x and it works fine. Attaching screenshots below.

Content section:
after1

Admin section:
after2

alison’s picture

On 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?)

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.

pminf’s picture

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

Last tests failed. Working on this during ContributionWeekend2022.

pminf’s picture

Status: Needs work » Needs review
FileSize
4.39 KB
4.15 KB

1) 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.

pminf’s picture

Corrected some wrong indentations in patch #80.

Asha Nair’s picture

FileSize
73.37 KB
183.38 KB

Applied patch #81 successfully. Works fine, sharing screenshots.

barone’s picture

Patch #81 applied successfully
Before patch
Code before patch #81 applied

After patch
Code after patch #81 applied

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."
WAI-ARIA documentation

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...

Manibharathi ER’s picture

FileSize
18.6 KB
20.03 KB

The patch works great, the aria-current=page added in pagination links.

Before Patch,

Before-patch

After Patch
After-patch

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.

Shubham Sharma 77’s picture

FileSize
71.46 KB
63.86 KB

Applied 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...

Meeni_Dhobale’s picture

Issue summary: View changes
FileSize
205.45 KB
182.65 KB

The 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

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
539.69 KB
639.62 KB

Testing patch #81
Verified issue without patch
Verified issue is fixed with patch

quietone’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -Novice

Starting 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.

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.

mgifford’s picture

Removing the accessibility maintainer review.

smustgrave’s picture

Status: Needs work » Needs review
FileSize
4.51 KB
4.54 KB

Oh 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?

DuaelFr’s picture

#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 the item.attributes output from their own templates (including contrib themes).

What do you think about it?

smustgrave’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs tests

I think that would be the best solution.

Also thing we should add simple test assertion that the attribute appears.

smustgrave’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
1.36 KB
1.86 KB

No interdiff as this is a new approach

The last submitted patch, 96: 2952488-96-tests-only.patch, failed testing. View results

pradipmodh13’s picture

Applied patch #96 applied successfully in drupal-10.1.x-dev.
We can move this ticket to RTBC.
Thanks for the patch.
Attached screenshot.

larowlan’s picture

Status: Needs review » Needs work

Looking good, one obvervation and a change required for the test changes in my book

  1. +++ b/core/includes/theme.inc
    @@ -1828,6 +1828,7 @@ function template_preprocess_pager(&$variables) {
           $items['pages'][$i]['attributes'] = new Attribute();
           if ($i == $pager_current) {
             $variables['current'] = $i;
    +        $items['pages'][$i]['attributes']['aria-current'] = t('Current page');
    

    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

  2. +++ b/core/modules/system/tests/src/Unit/Pager/PreprocessPagerTest.php
    @@ -39,6 +39,7 @@ protected function setUp(): void {
    @@ -51,16 +52,17 @@ public function testQuantityNotSet() {
    
    @@ -51,16 +52,17 @@ public function testQuantityNotSet() {
         require_once $this->root . '/core/includes/theme.inc';
         $variables = [
           'pager' => [
    -        '#element' => '',
    +        '#element' => '2',
             '#parameters' => [],
    -        '#quantity' => '',
    +        '#quantity' => '2',
    

    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

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.

smustgrave’s picture

Addressed points in #99

needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
86 bytes

The 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.

smustgrave’s picture

Status: Needs work » Needs review
FileSize
850 bytes
1.98 KB
andypost’s picture

+++ b/core/includes/theme.inc
@@ -1827,6 +1827,7 @@ function template_preprocess_pager(&$variables) {
+      $items['pages'][$i]['attributes']->setAttribute('aria-current', t('Current page'));

it could use new TranslatableMarkup instead of t()

andypost’s picture

Status: Needs review » Needs work
+++ b/core/modules/system/tests/src/Unit/Pager/PreprocessPagerTest.php
@@ -39,6 +39,7 @@ protected function setUp(): void {
+    $container->set('string_translation', $this->getStringTranslationStub());

@@ -63,4 +64,26 @@ public function testQuantityNotSet() {
+    $this->assertEquals('Current page', $variables['items']['pages']['2']['attributes']->offsetGet('aria-current')->__toString());

Please use \Drupal\Core\StringTranslation\TranslatableMarkup::getUntranslatedString() instead of testing string translation

smustgrave’s picture

@andypost not sure I follow #106?

andypost’s picture

Status: Needs work » Needs review
FileSize
2.34 KB
2.63 KB

I mean that)

andypost’s picture

FileSize
799 bytes
2.65 KB

Bit better wording

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Ah 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.

  • longwave committed 2f060c96 on 10.1.x
    Issue #2952488 by smustgrave, pminf, dcgoodwin, andypost, pau1_m, sim_1...
longwave’s picture

Status: Reviewed & tested by the community » Fixed

Backported 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:

--- a/core/modules/system/tests/src/Unit/Pager/PreprocessPagerTest.php
+++ b/core/modules/system/tests/src/Unit/Pager/PreprocessPagerTest.php
@@ -40,7 +40,7 @@ protected function setUp(): void {
     $container = new ContainerBuilder();
     $container->set('pager.manager', $pager_manager);
     $container->set('url_generator', $url_generator);
-    // The template_preprocess_pager() rendering translatable attribute values.
+    // template_preprocess_pager() renders translatable attribute values.
     $container->set('string_translation', $this->getStringTranslationStub());
     \Drupal::setContainer($container);
   }

  • longwave committed 38e90839 on 11.x
    Issue #2952488 by smustgrave, pminf, dcgoodwin, andypost, pau1_m, sim_1...
longwave’s picture

Version: 11.x-dev » 10.1.x-dev

Status: Fixed » Closed (fixed)

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

neclimdul’s picture

Looks like the value used for this attribute is incorrect. Filed a follow up

https://www.drupal.org/project/drupal/issues/3384679