Skip to content

Commit

Permalink
MDL-77150 core_table: Fix classes added as columnsattributes are ignored
Browse files Browse the repository at this point in the history
Fix columnattributes with key 'class' being ingored by adding them to every 'column_class'.
  • Loading branch information
roland04 committed Mar 1, 2023
1 parent 6458658 commit 3bb68ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/tablelib.php
Expand Up @@ -1143,6 +1143,12 @@ public function get_row_cells_html(string $rowid, array $row, ?array $suppressla
foreach ($row as $index => $data) {
$column = $colbyindex[$index];

$columnattributes = $this->columnsattributes[$column] ?? [];
if (isset($columnattributes['class'])) {
$this->column_class($column, $columnattributes['class']);
unset($columnattributes['class']);
}

$attributes = [
'class' => "cell c{$index}" . $this->column_class[$column],
'id' => "{$rowid}_c{$index}",
Expand All @@ -1155,7 +1161,7 @@ public function get_row_cells_html(string $rowid, array $row, ?array $suppressla
$attributes['scope'] = 'row';
}

$attributes += $this->columnsattributes[$column] ?? [];
$attributes += $columnattributes;

if (empty($this->prefs['collapse'][$column])) {
if ($this->column_suppress[$column] && $suppresslastrow !== null && $suppresslastrow[$index] === $data) {
Expand Down
4 changes: 4 additions & 0 deletions lib/upgrade.txt
@@ -1,6 +1,10 @@
This files describes API changes in core libraries and APIs,
information provided here is intended especially for developers.

=== 4.0.7 ===

* The method `flexible_table::set_columnsattributes` now can be used with 'class' key to add custom classes to the DOM.

=== 4.0.6 ===

* There is a new helper function mtrace_exception to help with reporting exceptions you have caught in scheduled tasks.
Expand Down

0 comments on commit 3bb68ae

Please sign in to comment.