Add "Table class" option to views table formatter UI

Created on 4 April 2019, over 5 years ago
Updated 11 February 2023, almost 2 years ago

Drupal 8 Follow-up of the Drupal 7 issue #1689472: add class to table in table format β†’ , which was committed on 2019-04-04.

Like before in Drupal 7 the Drupal 8 views table formatter only allows to set a class on rows in the UI but not on the table itself, while that would be consistent to other formatters and helpful in several cases.

How can one add a class to the rendered table when a view is outputted as table?

In html-list format for example one can add a class to a wrapper OR/AND to the list. Is this possible to the table as well?

Thanks!

✨ Feature request
Status

Needs work

Version

10.1 ✨

Component
ViewsΒ  β†’

Last updated about 5 hours ago

Created by

πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

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 issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

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

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request β†’ as a guide.

    Tagging. for an issue summary update following the standard template please.

    This feature request will require test coverage as well

    Thanks.

  • πŸ‡ΊπŸ‡ΈUnited States pcate
  • πŸ‡ΊπŸ‡ΈUnited States pcate

    @smustgrave I've updated the issue summary to follow the standard template.

  • Merge request !8749Add CSS class field to views table options. β†’ (Open) created by pcate
  • πŸ‡ΊπŸ‡ΈUnited States pcate

    I've made an initial conversion of @dieuwe #10 patch to a merge request.

  • Pipeline finished with Canceled
    4 months ago
    Total: 367s
    #222302
  • Pipeline finished with Success
    4 months ago
    Total: 559s
    #222306
  • Pipeline finished with Canceled
    4 months ago
    Total: 511s
    #222783
  • πŸ‡ΊπŸ‡ΈUnited States pcate
  • πŸ‡ΊπŸ‡ΈUnited States pcate

    It does appear the table style config schema needs to css class option added. The test I added was failing without it. Updated issue summary to reflect this.

  • πŸ‡ΊπŸ‡ΈUnited States pcate
  • Pipeline finished with Success
    4 months ago
    Total: 473s
    #222791
  • Status changed to Needs review 4 months ago
  • πŸ‡ΊπŸ‡ΈUnited States pcate

    Setting to "Needs Review". I added a functionality test to confirm functionality is working, and I also tested manually.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    GREAT work @PCate! RTBC! Removing the solved tags!

  • Status changed to RTBC 4 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Nice!

    So this is one of those cases test-only feature doesn't work as it reverts the schema change. So applied locally and reverted the changes but kept the schema, so the test will run

    Behat\Mink\Exception\ElementNotFoundException: Element matching xpath "//table[contains(concat(" ", @class, " "), " test-css-table-class1 test-css-table-class2 ")]" not found.
    

    Which shows the test itself.

    Believe this one is good. Only thing not 100% sure is if it will need a CR.

  • πŸ‡ΊπŸ‡ΈUnited States dalemoore

    Just testedβ€”working for me! This just made my day for reals.

    Screenshots below.

  • Status changed to Needs work 4 months ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone

    The issue summary clearly explains the problem and the change.

    This is changing the UI, adding tag. The latest before and after screenshots should be available from the issue summary to help reviewers and committers. I updated the IS to state that they are in #26. Testing was done in #25 and manual testing in #26.

    I read the MR and have commented on the user interface text.

  • Status changed to Needs review 4 months ago
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Thanks @quietone - you're right! Just did that, think you suggestion is good. I also added "Table" to the title to be even clearer about the context. Please review.

  • Pipeline finished with Success
    4 months ago
    Total: 593s
    #247520
  • Status changed to RTBC 3 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Believe feedback has been addressed here.

  • πŸ‡¬πŸ‡§United Kingdom longwave UK

    Does this need an update hook to add the empty class to any existing views that use the table style?

  • πŸ‡¬πŸ‡§United Kingdom catch

    #30 is correct, we need a post update for that, otherwise there will be mis-matches when someone next resaves the views UI or a different update runs, marking needs work.

  • Status changed to Needs work 29 days ago
  • πŸ‡ΊπŸ‡ΈUnited States pcate

    Is there any documentation on how to write config update hooks for views? My understanding is that it is different than regular update hooks?

  • Pipeline finished with Failed
    28 days ago
    Total: 161s
    #318852
  • πŸ‡ΊπŸ‡ΈUnited States pcate
  • Pipeline finished with Success
    28 days ago
    Total: 1267s
    #318858
  • πŸ‡ΊπŸ‡ΈUnited States pcate

    Using existing views update hooks as examples I tried adding an update hook for the table CSS class schema change. I also added the update hook task to the list of remaining tasks.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    So with addition of upgrade path will need a test for the that hook.

  • πŸ‡ΊπŸ‡ΈUnited States pcate
Production build 0.71.5 2024