From c3aba13f790e842168fe9b4664cd4e1d326a42dc Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Mon, 20 Jun 2022 12:45:52 +1000 Subject: [PATCH] MDL-68550 tablelib: Use aria-role=button Use the aria-role=button for: - show/hide links - sort links - reset table preferences link --- lib/tablelib.php | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/tablelib.php b/lib/tablelib.php index daaf4718e6f..2488defbc08 100644 --- a/lib/tablelib.php +++ b/lib/tablelib.php @@ -1232,20 +1232,26 @@ class flexible_table { $ariacontrols = trim($ariacontrols); if (!empty($this->prefs['collapse'][$column])) { - $linkattributes = array('title' => get_string('show') . ' ' . strip_tags($this->headers[$index]), - 'aria-expanded' => 'false', - 'aria-controls' => $ariacontrols, - 'data-action' => 'show', - 'data-column' => $column); + $linkattributes = [ + 'title' => get_string('show') . ' ' . strip_tags($this->headers[$index]), + 'aria-expanded' => 'false', + 'aria-controls' => $ariacontrols, + 'data-action' => 'show', + 'data-column' => $column, + 'role' => 'button', + ]; return html_writer::link($this->baseurl->out(false, array($this->request[TABLE_VAR_SHOW] => $column)), $OUTPUT->pix_icon('t/switch_plus', null), $linkattributes); } else if ($this->headers[$index] !== NULL) { - $linkattributes = array('title' => get_string('hide') . ' ' . strip_tags($this->headers[$index]), - 'aria-expanded' => 'true', - 'aria-controls' => $ariacontrols, - 'data-action' => 'hide', - 'data-column' => $column); + $linkattributes = [ + 'title' => get_string('hide') . ' ' . strip_tags($this->headers[$index]), + 'aria-expanded' => 'true', + 'aria-controls' => $ariacontrols, + 'data-action' => 'hide', + 'data-column' => $column, + 'role' => 'button', + ]; return html_writer::link($this->baseurl->out(false, array($this->request[TABLE_VAR_HIDE] => $column)), $OUTPUT->pix_icon('t/switch_minus', null), $linkattributes); } @@ -1664,6 +1670,7 @@ class flexible_table { 'data-sortable' => $this->is_sortable($column), 'data-sortby' => $column, 'data-sortorder' => $sortorder, + 'role' => 'button', ]) . ' ' . $this->sort_icon($isprimary, $order); } @@ -1861,7 +1868,7 @@ class flexible_table { $url = $this->baseurl->out(false, array($this->request[TABLE_VAR_RESET] => 1)); $html = html_writer::start_div('resettable mdl-right'); - $html .= html_writer::link($url, get_string('resettable')); + $html .= html_writer::link($url, get_string('resettable'), ['role' => 'button']); $html .= html_writer::end_div(); return $html;