MDL-70829 theme_boost: Make context header icons decorative

The non-empty alt text for the icons of the context header buttons like
the "Message" and the "Add contact" buttons cause redundant information
to be read twice by screen readers when the buttons are rendered with
the icon and the button name. The icons need to be set as decorative by
setting an empty alt text for them.
* The presentation role is also unnecessary.
* The alt text is needed when the button gets rendered without the
button name text.
This commit is contained in:
Jun Pataleta 2024-03-18 21:15:15 +08:00
parent dd29c50196
commit 87bacf1750
No known key found for this signature in database
GPG key ID: F83510526D99E2C7
4 changed files with 17 additions and 8 deletions

View file

@ -28,7 +28,12 @@
}
}}
<span>
{{#pix}} t/addcontact, core, {{#str}} addtoyourcontacts, message {{/str}} {{/pix}}
{{#displaytextlabel}}<span class="header-button-title">{{#str}} addtoyourcontacts, message {{/str}}</span>{{/displaytextlabel}}
{{^displaytextlabel}}
{{#pix}} t/addcontact, core, {{#str}} addtoyourcontacts, message {{/str}} {{/pix}}
{{/displaytextlabel}}
{{#displaytextlabel}}
{{#pix}} t/addcontact, core {{/pix}}
<span class="header-button-title">{{#str}} addtoyourcontacts, message {{/str}}</span>
{{/displaytextlabel}}
</span>
{{> core/loading }}

View file

@ -28,7 +28,12 @@
}
}}
<span>
{{#pix}} t/removecontact, core, {{#str}} removefromyourcontacts, message {{/str}} {{/pix}}
{{#displaytextlabel}}<span class="header-button-title">{{#str}} removefromyourcontacts, message {{/str}}</span>{{/displaytextlabel}}
{{^displaytextlabel}}
{{#pix}} t/removecontact, core, {{#str}} removefromyourcontacts, message {{/str}} {{/pix}}
{{/displaytextlabel}}
{{#displaytextlabel}}
{{#pix}} t/removecontact, core {{/pix}}
<span class="header-button-title">{{#str}} removefromyourcontacts, message {{/str}}</span>
{{/displaytextlabel}}
</span>
{{> core/loading }}

View file

@ -61,7 +61,7 @@ Feature: Self conversation
Given I log in as "student1"
When I follow "Profile" in the user menu
Then I should see "Message"
And I click on "Message" "icon"
And I press "Message"
And I send "Hi!" message in the message area
And I should see "Hi!" in the "Student 1" "core_message > Message conversation"
And I should see "##today##%d %B##" in the "Student 1" "core_message > Message conversation"

View file

@ -224,15 +224,14 @@ class core_renderer extends \core_renderer {
if ($button['buttontype'] === 'message') {
\core_message\helper::messageuser_requirejs();
}
$image = $this->pix_icon($button['formattedimage'], $button['title'], 'moodle', array(
$image = $this->pix_icon($button['formattedimage'], '', 'moodle', array(
'class' => 'iconsmall',
'role' => 'presentation'
));
$image .= html_writer::span($button['title'], 'header-button-title');
} else {
$image = html_writer::empty_tag('img', array(
'src' => $button['formattedimage'],
'role' => 'presentation'
'alt' => $button['title'],
));
}
$html .= html_writer::link($button['url'], html_writer::tag('span', $image), $button['linkattributes']);