diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 55e19c4fc30..e465469e338 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -222,6 +222,8 @@ $string['block'] = 'Block'; $string['blockconfiga'] = 'Configuring a {$a} block'; $string['blockconfigbad'] = 'This block has not been implemented correctly and thus cannot provide a configuration interface.'; $string['blocks'] = 'Blocks'; +$string['blocks_main'] = 'Main content blocks'; +$string['blocks_supplementary'] = 'Supplementary blocks'; $string['blocksaddedit'] = 'Add/Edit blocks'; $string['blockseditoff'] = 'Blocks editing off'; $string['blocksediton'] = 'Blocks editing on'; diff --git a/lib/classes/output/core_renderer.php b/lib/classes/output/core_renderer.php index 592a1f72476..99a156e0f2c 100644 --- a/lib/classes/output/core_renderer.php +++ b/lib/classes/output/core_renderer.php @@ -3817,6 +3817,7 @@ EOD; */ public function blocks($region, $classes = [], $tag = 'aside', $fakeblocksonly = false) { $displayregion = $this->page->apply_theme_region_manipulations($region); + $headingid = $displayregion . '-block-region-heading'; $classes = (array)$classes; $classes[] = 'block-region'; $attributes = [ @@ -3824,12 +3825,23 @@ EOD; 'class' => join(' ', $classes), 'data-blockregion' => $displayregion, 'data-droptarget' => '1', + 'aria-labelledby' => $headingid, ]; + // Generate an appropriate heading to uniquely identify the block region. + $blocksheading = match ($displayregion) { + 'side-post' => get_string('blocks_supplementary'), + 'content' => get_string('blocks_main'), + default => get_string('blocks'), + }; + $content = html_writer::tag('h2', $blocksheading, ['class' => 'visually-hidden', 'id' => $headingid]); if ($this->page->blocks->region_has_content($displayregion, $this)) { - $content = html_writer::tag('h2', get_string('blocks'), ['class' => 'visually-hidden']) . - $this->blocks_for_region($displayregion, $fakeblocksonly); - } else { - $content = html_writer::tag('h2', get_string('blocks'), ['class' => 'visually-hidden']); + $content .= $this->blocks_for_region($displayregion, $fakeblocksonly); + } + // Given that