From b0b3a535215abdd113f1df504d7c52c76cab1d54 Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Sat, 5 Dec 2020 00:57:47 +1100 Subject: [PATCH 1/7] MDL-70173 output: use an empty alt to hide user pic from screen readers There is no need to use WAI-ARIA to hide images from screen readers. See https://www.w3.org/WAI/tutorials/images/decorative/ --- blocks/online_users/block_online_users.php | 3 ++- lib/outputrenderers.php | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/blocks/online_users/block_online_users.php b/blocks/online_users/block_online_users.php index dbdf802097b..e44468cae6a 100644 --- a/blocks/online_users/block_online_users.php +++ b/blocks/online_users/block_online_users.php @@ -126,7 +126,8 @@ class block_online_users extends block_base { } else { // Not a guest user. $this->content->text .= '
'; $this->content->text .= ''; - $this->content->text .= $OUTPUT->user_picture($user, array('size'=>16, 'alttext'=>false, 'link'=>false)) .$user->fullname.'
'; + $avataroptions = ['size' => 16, 'visibletoscreenreaders' => false, 'link' => false]; + $this->content->text .= $OUTPUT->user_picture($user, $avataroptions) . $user->fullname . ''; if ($USER->id == $user->id) { if ($CFG->block_online_users_onlinestatushiding) { diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 222eaf33b69..6dc864ffbbc 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -2523,8 +2523,6 @@ class core_renderer extends renderer_base { * @return string */ protected function render_user_picture(user_picture $userpicture) { - global $CFG, $DB; - $user = $userpicture->user; $canviewfullnames = has_capability('moodle/site:viewfullnames', $this->page->context); @@ -2557,11 +2555,10 @@ class core_renderer extends renderer_base { $attributes = array('src' => $src, 'class' => $class, 'width' => $size, 'height' => $size); if (!$userpicture->visibletoscreenreaders) { $alt = ''; - $attributes['aria-hidden'] = 'true'; } + $attributes['alt'] = $alt; if (!empty($alt)) { - $attributes['alt'] = $alt; $attributes['title'] = $alt; } From a6578dd64fbb6e9621a818c9007816a58ea9aed7 Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Sat, 5 Dec 2020 03:59:51 +1100 Subject: [PATCH 2/7] MDL-70173 message: Fix empty link --- message/templates/message_drawer.mustache | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/message/templates/message_drawer.mustache b/message/templates/message_drawer.mustache index c29d841aa78..c3440ba08f0 100644 --- a/message/templates/message_drawer.mustache +++ b/message/templates/message_drawer.mustache @@ -37,8 +37,10 @@ {{$drawercontent}}
From 3a9fa051c36a5dcdfe686aeb4cf5d7b233828b3d Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Mon, 7 Dec 2020 01:43:45 +1100 Subject: [PATCH 3/7] MDL-70173 dashboard: ARIA role presentation conflicted the empty alt The markup alt text is contradictory. According to https://www.w3.org/TR/2017/WD-wai-aria-practices-1.1-20170628/examples/presentation/PresentationRoleExamples.html It is recommended that authors instead use empty alt text (alt="") where they use role="presentation". --- .../templates/recentlyaccessedcourses-view.mustache | 3 +-- blocks/timeline/templates/event-list.mustache | 3 +-- blocks/timeline/templates/view-courses.mustache | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/blocks/recentlyaccessedcourses/templates/recentlyaccessedcourses-view.mustache b/blocks/recentlyaccessedcourses/templates/recentlyaccessedcourses-view.mustache index 9a0bdb4db2c..0b2ef5d4eaf 100644 --- a/blocks/recentlyaccessedcourses/templates/recentlyaccessedcourses-view.mustache +++ b/blocks/recentlyaccessedcourses/templates/recentlyaccessedcourses-view.mustache @@ -45,8 +45,7 @@
diff --git a/blocks/timeline/templates/event-list.mustache b/blocks/timeline/templates/event-list.mustache index 83c3b8aa3dd..999d1fba766 100644 --- a/blocks/timeline/templates/event-list.mustache +++ b/blocks/timeline/templates/event-list.mustache @@ -46,8 +46,7 @@