Skip to content

Commit

Permalink
MDL-70173 output: All pages should have a heading
Browse files Browse the repository at this point in the history
In MDL-63040, it was decided that the page header for the dashboad page
should be removed.
However, Based on Success Criteria 1.3.1 and 2.4.6 from the WebAIM's
WCAG 2 Checklist, all pages should have an <h1> element.
So I put an sr-only heading on the dashboard and all other pages, where
no page header is shown.
  • Loading branch information
rezaies committed Feb 9, 2021
1 parent 3fcb116 commit ca6a8df
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/outputrenderers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4240,9 +4240,17 @@ public function render_skip_links($links) {
*/
protected function render_context_header(context_header $contextheader) {

// Generate the heading first and before everything else as we might have to do an early return.
if (!isset($contextheader->heading)) {
$heading = $this->heading($this->page->heading, $contextheader->headinglevel);
} else {
$heading = $this->heading($contextheader->heading, $contextheader->headinglevel);
}

$showheader = empty($this->page->layout_options['nocontextheader']);
if (!$showheader) {
return '';
// Return the heading wrapped in an sr-only element so it is only visible to screen-readers.
return html_writer::div($heading, 'sr-only');
}

// All the html stuff goes here.
Expand All @@ -4255,13 +4263,7 @@ protected function render_context_header(context_header $contextheader) {
}

// Headings.
if (!isset($contextheader->heading)) {
$headings = $this->heading($this->page->heading, $contextheader->headinglevel);
} else {
$headings = $this->heading($contextheader->heading, $contextheader->headinglevel);
}

$html .= html_writer::tag('div', $headings, array('class' => 'page-header-headings'));
$html .= html_writer::tag('div', $heading, array('class' => 'page-header-headings'));

// Buttons.
if (isset($contextheader->additionalbuttons)) {
Expand Down

0 comments on commit ca6a8df

Please sign in to comment.