Allow setting header row attributes in table.html.twig

Created on 13 February 2024, 11 months ago
Updated 7 March 2024, 10 months ago

Problem/Motivation

table.html.twig allows setting attributes on the tr elements inside tbody, but not the one inside thead. It would be useful to be able to do this.

Proposed resolution

#header is currently an array of cells. Make it so that if #header contains the key cells, then that is interpreted to be an array of cells and any values in the key row_attributes are added as attributes on the tr.

Remaining tasks

Agree on form of #header. Implement in table.html.twig and template_preprocess_table().

User interface changes

None.

API changes

Additional keys in #header.

Data model changes

None.

Release notes snippet

✨ Feature request
Status

Needs work

Version

11.0 🔥

Component
Theme  →

Last updated 24 minutes ago

Created by

🇨🇦Canada Liam Morland Ontario, CA 🇨🇦

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs change record

    A change record needs to be drafted before an issue is committed. Note: Change records used to be called change notifications.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @Liam Morland
  • First commit to issue fork.
  • 🇮🇳India shubhamsprasad

    shubhamsprasad → changed the visibility of the branch 3421188-allow-setting-header to hidden.

  • First commit to issue fork.
  • Pipeline finished with Failed
    10 months ago
    Total: 202s
    #103143
  • Pipeline finished with Success
    10 months ago
    Total: 783s
    #103146
  • Status changed to Needs review 10 months ago
  • 🇮🇳India govind_giri_goswami

    In both the table.html.twig template and the template_preprocess_table() function, we enabled the addition of attributes to the

  • Status changed to Needs work 10 months ago
  • 🇺🇸United States smustgrave

    Did a small review but seems to be a number of scope changes.

    Solution doesn't match the proposed solution

    Will need test coverage

    If editing a core template they all will have to be updated and CR written.

  • Pipeline finished with Failed
    10 months ago
    Total: 184s
    #110103
  • Pipeline finished with Success
    10 months ago
    Total: 520s
    #110119
  • Status changed to Needs review 10 months ago
  • 🇮🇳India govind_giri_goswami

    The modifications to the template_preprocess_table() function enable the setting of attributes for tr elements within the thead of the table. This is achieved by introducing a check for row_attributes within the loop that processes header cells. If row_attributes are present, they are assigned to the respective header cell. Additionally, the row_attributes are merged with existing cell_attributes to ensure preservation of both cell and row attributes.

  • Status changed to Needs work 10 months ago
  • 🇺🇸United States smustgrave

    Still seems out of scope changes are still there.

    Still missing tests

    See just one template is updated and not the others.

    No change record.

  • Pipeline finished with Success
    10 months ago
    Total: 543s
    #114015
  • Status changed to Needs review 10 months ago
  • 🇮🇳India govind_giri_goswami

    improved MR

  • Status changed to Needs work 10 months ago
  • 🇺🇸United States smustgrave

    #10 still applies

Production build 0.71.5 2024