Problem/Motivation
CivicTheme table does not render cell or row attributes causing issues with some Drupal elements such as table drag.
This is blocking fixing layout builder completely
Steps to reproduce
Click `move` block in Layout builder.
Note the off canvas diaglog has weight and row but the draggable table is not working.
Proposed resolution
Untested, draft solution - update preprocess code:
foreach (['rows', 'footer'] as $section) {
$rows = [];
if (!empty($variables[$section])) {
foreach ($variables[$section] as $row_key => $row) {
$row_cells = $row['cells'] ?? $row['columns'] ?? [];
$rows[$row_key] = [
'attributes' => $row['attributes'] ?? [],
];
foreach ($row_cells as $cell) {
$cell_attributes = $cell['attributes'] ?? new Attribute();
$inner_attributes = new Attribute($cell['content']['#attributes'] ?? []);
$cell_attributes->merge($inner_attributes);
$cell_content = $cell['content'] ?? '';
$cell_content = civictheme_render($cell_content);
$cell_content = _civictheme_process__html_content($cell_content);
$rows[$row_key]['cols'][] = [
'content' => [
'#type' => 'markup',
'#markup' => $cell_content,
],
'attributes' => $cell_attributes,
];
}
}
}
Update component:
{% for row in rows %}
<tr {{ row.attributes }}>
{% for col in row.cols %}
{% if header is not empty %}
{% if header_sanitized is not empty and header_sanitized[loop.index0] is defined %}
{% set data_title = header_sanitized[loop.index0] %}
{% else %}
{% set data_title = header[loop.index0] is defined ? header[loop.index0] : '' %}
{% endif %}
{% endif %}
<td {{ col.attributes }}{% if data_title is defined %}data-title="{{ data_title|striptags }}"{% endif %}>
{{ col.content }}
</td>
{% endfor %}
</tr>
{% endfor %}
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
richardgaunt commentedComment #3
fionamorrison23 commentedComment #4
richardgaunt commented