From 371f59c20b2ddb8564ade9ee23da2e042b6734cf Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Tue, 19 Mar 2024 00:04:11 +0800 Subject: [PATCH] MDL-70829 core: Set the icon of action icons as a decorative image * When text is rendered for the action icon, set the icon as a decorative image by setting empty alt and title attributes and adding the aria-hidden attribute as well. Otherwise, assistive technologies will read the action name twice. --- lib/outputrenderers.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 45b2dccd752..2866dbe64fa 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -2117,14 +2117,19 @@ class core_renderer extends renderer_base { $attributes['class'] = 'action-icon'; } - $icon = $this->render($pixicon); - if ($linktext) { $text = $pixicon->attributes['alt']; + // Set the icon as a decorative image if we're displaying the action text. + // Otherwise, the action name will be read twice by assistive technologies. + $pixicon->attributes['alt'] = ''; + $pixicon->attributes['title'] = ''; + $pixicon->attributes['aria-hidden'] = 'true'; } else { $text = ''; } + $icon = $this->render($pixicon); + return $this->action_link($url, $text.$icon, $action, $attributes); }