MDL-69008 core: Fix accessibility issues in paged content templates

* Added menuitem role for the "Show x per page" menu.
* Added appropriate aria-labels for the links in the paging bar.
This commit is contained in:
Jun Pataleta 2020-06-10 23:18:10 +08:00 committed by Sara Arjona
parent e2ef786003
commit b9518bf811
4 changed files with 70 additions and 8 deletions

View file

@ -854,6 +854,7 @@ $string['first'] = 'First';
$string['firstaccess'] = 'First access'; $string['firstaccess'] = 'First access';
$string['firstname'] = 'First name'; $string['firstname'] = 'First name';
$string['firstnamephonetic'] = 'First name - phonetic'; $string['firstnamephonetic'] = 'First name - phonetic';
$string['firstpage'] = 'First page';
$string['firstsiteaccess'] = 'First access to site'; $string['firstsiteaccess'] = 'First access to site';
$string['firsttime'] = 'Is this your first time here?'; $string['firsttime'] = 'Is this your first time here?';
$string['folder'] = 'Folder'; $string['folder'] = 'Folder';
@ -1133,6 +1134,7 @@ $string['lastlogin'] = 'Last login';
$string['lastmodified'] = 'Last modified'; $string['lastmodified'] = 'Last modified';
$string['lastname'] = 'Surname'; $string['lastname'] = 'Surname';
$string['lastnamephonetic'] = 'Surname - phonetic'; $string['lastnamephonetic'] = 'Surname - phonetic';
$string['lastpage'] = 'Last page';
$string['lastsiteaccess'] = 'Last access to site'; $string['lastsiteaccess'] = 'Last access to site';
$string['lastyear'] = 'Last year'; $string['lastyear'] = 'Last year';
$string['latestlanguagepack'] = 'Check for latest language pack on moodle.org'; $string['latestlanguagepack'] = 'Check for latest language pack on moodle.org';
@ -1417,6 +1419,7 @@ Cheers from the \'{$a->sitename}\' administrator,
$string['newusers'] = 'New users'; $string['newusers'] = 'New users';
$string['newwindow'] = 'New window'; $string['newwindow'] = 'New window';
$string['next'] = 'Next'; $string['next'] = 'Next';
$string['nextpage'] = 'Next page';
$string['nextsection'] = 'Next section'; $string['nextsection'] = 'Next section';
$string['no'] = 'No'; $string['no'] = 'No';
$string['noblockstoaddhere'] = 'There are no blocks that you can add to this page.'; $string['noblockstoaddhere'] = 'There are no blocks that you can add to this page.';
@ -1600,6 +1603,7 @@ $string['preview'] = 'Preview';
$string['previeworchoose'] = 'Preview or choose a theme'; $string['previeworchoose'] = 'Preview or choose a theme';
$string['previous'] = 'Previous'; $string['previous'] = 'Previous';
$string['previouslyselectedusers'] = 'Previously selected users not matching \'{$a}\''; $string['previouslyselectedusers'] = 'Previously selected users not matching \'{$a}\'';
$string['previouspage'] = 'Previous page';
$string['previoussection'] = 'Previous section'; $string['previoussection'] = 'Previous section';
$string['primaryadminsetup'] = 'Setup administrator account'; $string['primaryadminsetup'] = 'Setup administrator account';
$string['privacy:metadata:config_log'] = 'The log of configuration changes.'; $string['privacy:metadata:config_log'] = 'The log of configuration changes.';

View file

@ -23,11 +23,17 @@
Example context (json): Example context (json):
{ {
"pagingbar": { "pagingbar": {
"itemsperpage": 1, "showitemsperpageselector": true,
"itemsperpage": [
{ "value": 5, "active": false },
{ "value": 10, "active": true },
{ "value": 15, "active": false }
],
"previous": true, "previous": true,
"next": true, "next": true,
"first": true, "first": true,
"last": true, "last": true,
"barsize": 5,
"pages": [ "pages": [
{ {
"page": "1", "page": "1",
@ -36,6 +42,26 @@
{ {
"url": "#", "url": "#",
"page": "2" "page": "2"
},
{
"url": "#",
"page": "3"
},
{
"url": "#",
"page": "4"
},
{
"url": "#",
"page": "5"
},
{
"url": "#",
"page": "6"
},
{
"url": "#",
"page": "7"
} }
] ]
}, },
@ -48,6 +74,26 @@
{ {
"page": 2, "page": 2,
"content": "<p>Some page 2 content</p>" "content": "<p>Some page 2 content</p>"
},
{
"page": 3,
"content": "<p>Some page 3 content</p>"
},
{
"page": 4,
"content": "<p>Some page 4 content</p>"
},
{
"page": 5,
"content": "<p>Some page 5 content</p>"
},
{
"page": 6,
"content": "<p>Some page 6 content</p>"
},
{
"page": 7,
"content": "<p>Some page 7 content</p>"
} }
] ]
} }

View file

@ -22,7 +22,12 @@
Example context (json): Example context (json):
{ {
"itemsperpage": 2, "showitemsperpageselector": true,
"itemsperpage": [
{ "value": 5, "active": false },
{ "value": 10, "active": true },
{ "value": 15, "active": false }
],
"previous": true, "previous": true,
"next": true, "next": true,
"first": true, "first": true,
@ -89,7 +94,8 @@
<a <a
class="dropdown-item {{#active}}active{{/active}}" class="dropdown-item {{#active}}active{{/active}}"
href="#" href="#"
data-limit={{value}} data-limit="{{value}}"
role="menuitem"
{{#active}}aria-current="true"{{/active}} {{#active}}aria-current="true"{{/active}}
> >
{{#value}}{{.}}{{/value}} {{#value}}{{.}}{{/value}}
@ -149,6 +155,7 @@
<ul class="pagination mb-0"> <ul class="pagination mb-0">
{{#previous}} {{#previous}}
{{< core/paged_content_paging_bar_item }} {{< core/paged_content_paging_bar_item }}
{{$linkattributes}}aria-label="{{#str}}previouspage{{/str}}"{{/linkattributes}}
{{$item-content}} {{$item-content}}
<span class="icon-no-margin dir-rtl-hide" aria-hidden="true">{{#pix}} i/previous, core {{/pix}}</span> <span class="icon-no-margin dir-rtl-hide" aria-hidden="true">{{#pix}} i/previous, core {{/pix}}</span>
<span class="icon-no-margin dir-ltr-hide" aria-hidden="true">{{#pix}} i/next, core {{/pix}}</span> <span class="icon-no-margin dir-ltr-hide" aria-hidden="true">{{#pix}} i/next, core {{/pix}}</span>
@ -158,16 +165,18 @@
{{/previous}} {{/previous}}
{{#first}} {{#first}}
{{< core/paged_content_paging_bar_item }} {{< core/paged_content_paging_bar_item }}
{{$linkattributes}}aria-label="{{#str}}firstpage{{/str}}"{{/linkattributes}}
{{$item-content}} {{$item-content}}
<span aria-hidden="true">{{#str}}first{{/str}}</span> {{#str}}first{{/str}}
{{/item-content}} {{/item-content}}
{{$attributes}}data-control="first"{{/attributes}} {{$attributes}}data-control="first"{{/attributes}}
{{/ core/paged_content_paging_bar_item }} {{/ core/paged_content_paging_bar_item }}
{{/first}} {{/first}}
{{#barsize}} {{#barsize}}
{{< core/paged_content_paging_bar_item }} {{< core/paged_content_paging_bar_item }}
{{$linkattributes}}aria-hidden="true"{{/linkattributes}}
{{$item-content}} {{$item-content}}
<span aria-hidden="true">&hellip;</span> &hellip;
{{/item-content}} {{/item-content}}
{{$attributes}}data-dots="beginning"{{/attributes}} {{$attributes}}data-dots="beginning"{{/attributes}}
{{/ core/paged_content_paging_bar_item }} {{/ core/paged_content_paging_bar_item }}
@ -179,22 +188,25 @@
{{/pages}} {{/pages}}
{{#barsize}} {{#barsize}}
{{< core/paged_content_paging_bar_item }} {{< core/paged_content_paging_bar_item }}
{{$linkattributes}}aria-hidden="true"{{/linkattributes}}
{{$item-content}} {{$item-content}}
<span aria-hidden="true">&hellip;</span> &hellip;
{{/item-content}} {{/item-content}}
{{$attributes}}data-dots="ending"{{/attributes}} {{$attributes}}data-dots="ending"{{/attributes}}
{{/ core/paged_content_paging_bar_item }} {{/ core/paged_content_paging_bar_item }}
{{/barsize}} {{/barsize}}
{{#last}} {{#last}}
{{< core/paged_content_paging_bar_item }} {{< core/paged_content_paging_bar_item }}
{{$linkattributes}}aria-label="{{#str}}lastpage{{/str}}"{{/linkattributes}}
{{$item-content}} {{$item-content}}
<span aria-hidden="true">{{#str}}last{{/str}}</span> {{#str}}last{{/str}}
{{/item-content}} {{/item-content}}
{{$attributes}}data-control="last"{{/attributes}} {{$attributes}}data-control="last"{{/attributes}}
{{/ core/paged_content_paging_bar_item }} {{/ core/paged_content_paging_bar_item }}
{{/last}} {{/last}}
{{#next}} {{#next}}
{{< core/paged_content_paging_bar_item }} {{< core/paged_content_paging_bar_item }}
{{$linkattributes}}aria-label="{{#str}}nextpage{{/str}}"{{/linkattributes}}
{{$item-content}} {{$item-content}}
<span class="icon-no-margin dir-rtl-hide" aria-hidden="true">{{#pix}} i/next, core {{/pix}}</span> <span class="icon-no-margin dir-rtl-hide" aria-hidden="true">{{#pix}} i/next, core {{/pix}}</span>
<span class="icon-no-margin dir-ltr-hide" aria-hidden="true">{{#pix}} i/previous, core {{/pix}}</span> <span class="icon-no-margin dir-ltr-hide" aria-hidden="true">{{#pix}} i/previous, core {{/pix}}</span>

View file

@ -33,7 +33,7 @@
<a href="{{#url}}{{.}}{{/url}}{{^url}}#{{/url}}" <a href="{{#url}}{{.}}{{/url}}{{^url}}#{{/url}}"
class="page-link" class="page-link"
data-region="page-link"> data-region="page-link" {{$linkattributes}}aria-label="{{#str}}pagea, moodle, {{page}}{{/str}}"{{/linkattributes}}>
{{$item-content}} {{$item-content}}
{{{page}}} {{{page}}}
{{/item-content}} {{/item-content}}