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

richardgaunt created an issue. See original summary.

richardgaunt’s picture

fionamorrison23’s picture

Assigned: Unassigned » joshua1234511
Issue tags: +civictheme-release-1.13
richardgaunt’s picture

Assigned: joshua1234511 » danielgry
Status: Active » Needs review

  • b1c3072c committed on 1.x
    Issue #3570945 by richardgaunt, joshua1234511, fionamorrison23:...