From df486967e48064f20898fcf7f660b25fbebdb284 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Thu, 28 Aug 2025 18:34:11 +0800 Subject: [PATCH] MDL-86490 output: Mark icon in action_icon as decorative --- public/lib/classes/output/core_renderer.php | 22 +++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/public/lib/classes/output/core_renderer.php b/public/lib/classes/output/core_renderer.php index d4b87f91953..967afd7521b 100644 --- a/public/lib/classes/output/core_renderer.php +++ b/public/lib/classes/output/core_renderer.php @@ -1661,14 +1661,20 @@ class core_renderer extends renderer_base { $attributes['class'] = 'action-icon'; } - 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 = $pixicon->attributes['alt']; + // Set the icon as a decorative image. The accessible label should be within the link itself and not the icon. + $pixicon->attributes['alt'] = ''; + $pixicon->attributes['title'] = ''; + $pixicon->attributes['aria-hidden'] = 'true'; + + $attributes['class'] .= ' mx-1 p-1'; + if (!$linktext) { + // Set a title attribute on the link for sighted users if no text is shown. + $attributes['title'] = $text; + // Style the icon button for increased target area. + $attributes['class'] .= ' btn btn-link icon-no-margin'; + // Make the action text only available to screen readers. + $attributes['aria-label'] = $text; $text = ''; } -- 2.43.0