Table display style places custom field class on table cell rather than field element

Created on 11 April 2014, over 10 years ago
Updated 6 November 2023, about 1 year ago

Steps to reproduce the problem

  1. Create a view using the table display style.
  2. Edit the default field added (Content: Title (Title)).
  3. Open the "Style Settings" dropdown and check "customize field HTML." Choose any HTML element (for this example I'm using P).
  4. Check "create a CSS class" and enter a class (for this example I'm using "p-class").
  5. Apply, save, and view the page.

Expected behavior

The HTML for the table cell should look something like:

<td class="views-field views-field-title" headers="view-title-table-column">
<p class="p-class">
<a href="/node/2">title2</a>
</p>
</td>

Actual behavior

<td class="views-field views-field-title p-class" headers="view-title-table-column">
<p>
<a href="/node/2">title2</a>
</p>
</td>

Analysis

The custom class is being placed on the wrapper table cell rather than the HTML element being specified. If you switch to unformatted list style, the class is correctly applied to the P element.

If I am specifying the element I want to wrap the field, the option just below it to specify a class seems like it would apply to that element, not the parent table cell. And it doesn't seem like this behavior should change based on the display style, as it does now.

This behavior is also present in views contrib in Drupal 7.x-3.x. It is related to #1368436: Customize field HTML css class with multiple fields in a column β†’ , though that is about what happens to classes on combined fields, whereas this appears to any and every field within a table style.

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
ViewsΒ  β†’

Last updated about 14 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States rootwork πŸ‡ΊπŸ‡Έ US-Pacific 🌎 Chinook (Multnomah, Clackamas) & Cowlitz lands 🌹 Portland, OR

Live updates comments and jobs are added and updated live.
  • VDC

    Related to the Views in Drupal Core initiative.

  • 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.

  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

  • GiftofOpenSource

    Take part in Pantheon's 2021 Gift of Open Source - all contributions and expertise levels welcome!

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.71.5 2024