Field attributes like CSS class names carry through to the field label attributes too.

Created on 5 October 2022, over 1 year ago
Updated 27 December 2023, 6 months ago

Problem/Motivation

Issue 2893331 β†’ 's patch caused the field's outer wrapper's attributes, such as the field class names, to carry through to the field's label for minimal and reset field templates. This update could have significant impact on a site depending upon how the CSS class names may be used, from functionality (e.g. JavaScript selectors) to appearance (e.g. CSS styles).

Proposed resolution

Update templates/ds-field-reset.html.twig and templates/ds-field-minimal.html.twig, replacing:

<div{{ attributes.addClass(title_classes) }}>

With:

<div{{ create_attribute({'class': title_classes}) }}>

Note, the attributes variable was previously specific to the field's outer wrapper. Now it's being used for BOTH the field's outer wrapper AND the field's label.

Example output BEFORE applying the above update:

<div class="field field-name-field-example">
  <div class="field field-name-field-example field-label-above">Example</div>
  Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>

Example output AFTER applying the above update:

<div class="field field-name-field-example">
  <div class="field-label-above">Example</div>
  Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>

Remaining tasks

I'm not sure if simply creating and committing a patch is now an option as theme builders may now be using these new classes but doing so may be a bit unusually as it would require the theme builders to use something like .field > .field or .field-name-field-FIELDNAME > .field-name-field-FIELDNAME to target the labels when they'd more likely use the .field-label-above, .field-label-inline, or .field-label-visually-hidden classes. As it currently exists, this bug is likely to create more problems on existing site than reverting the consequential changes caused by 2893331 β†’ 's patch.

πŸ› Bug report
Status

Closed: outdated

Version

3.0

Component

User interface

Created by

πŸ‡ΊπŸ‡ΈUnited States Christian DeLoach

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024