After recent update from 8.8 to 8.9 a field now shows up when ever a a grouping is used. it matters not what field is exposed. It is a collapsed field directly above the table and says "details" It is in a collapsed field/element.

I narrowed it down to the field in TABLE:SETTINGS at the bottom called "Table Details", there is nothing in it but there is also no way to disable it.

details

Step to reproduce:

  • Take a view with table display (say the content view)
  • Go to the table settings
  • set Grouping field Nr.1 to 'content type'
  • save settings
  • check the preview and see that this now shows the 'detail' as shown in the screenshot

Comments

joaomachado created an issue. See original summary.

joaomachado’s picture

Issue summary: View changes
jddh’s picture

Me too on 8.9.0. What the heck is this?

honza pobořil’s picture

Status: Active » Needs review
StatusFileSize
new1.62 KB

This could be solution.

lendude’s picture

Issue summary: View changes

Did a little debugging to figure out why this would be. This happens when $variables['caption_needed'] gets set to true for a different reason then the summary or description.

So the fix in #4 makes sense, maybe with a little tweak?

+++ b/core/modules/views/views.theme.inc
@@ -664,19 +664,21 @@ function template_preprocess_views_view_table(&$variables) {
+  if (!empty($handler->options['description'])) {
...
+      '#title' => $handler->options['summary'],

shouldn't we also check $handler->options['summary']

lendude’s picture

Issue tags: -Needs tests
StatusFileSize
new1.64 KB
new756 bytes
new2.4 KB

Here we go. Added a test and updated the fix a bit.

lauriii’s picture

Status: Needs review » Reviewed & tested by the community

This condition exists in the Twig template before #3119279: views-view-table.html.twig template directly uses details without render array and polyfills and it seems we somehow missed it:

+++ b/core/modules/views/templates/views-view-table.html.twig
@@ -47,15 +48,8 @@
-    {% if (summary is not empty) or (description is not empty) %}

+1 to the change and thank you for adding test coverage for this.

The last submitted patch, 7: 3149930-7-TEST_ONLY.patch, failed testing. View results

dww’s picture

A) Sorry we missed this! Ugh. 🤦‍♂️

B) Happy to report #7 applies cleanly to 9.1.x branch, too. Should be a simple commit + cherry-pick scenario.

C)

+++ b/core/modules/views/views.theme.inc
@@ -664,19 +664,21 @@ function template_preprocess_views_view_table(&$variables) {
+  if (!empty($handler->options['summary']) || !empty($handler->options['description'])) {
...
+      '#title' => $handler->options['summary'],
...
+          'description' => $handler->options['description'],

We use both, shouldn't we test that both have a value? Don't we want && here?

I tested via the Views UI -- looks like if you define a summary title, and leave a blank description, you at least end up with an empty string saved in the options, so there won't be a PHP warning with an undefined array key for description. You just get an empty <details>. I suppose if someone wanted to have just a summary and no description, we should let them:

Views table with a summary title without a summary description.

Also tried saving a description, then going back to clear out the title, and saving the view. You end up with a "raw" <details>, without the <summary>, but it does work:

Views table with a summary description without a summary title.

Convinced myself this is RTBC. ;) +1.

Thanks/sorry,
-Derek

dww’s picture

Title: Views TABLE Settings - exposes "Details" field when grouping is used » Views table settings exposes "Details" field even when empty

Also, this bug has nothing (specifically) to do with the grouping setting. Other table settings will trigger it, such as "Caption for the table". Giving this a more generic title for the commit and history.

Thanks,
-Derek

phernand42’s picture

Patch in #7 works for me

joaomachado’s picture

Patch #7 works, everything is as it should be.

joelpittet’s picture

Ran into this today, thanks for patching and adding a test @Lendude! RTBC++

yuanyuan.zhang’s picture

When there's caption the if statement is always true and renders a tag, applied the patch in #7 and it works fine, thanks for the work!

chuchunaku’s picture

Patch in #7 works for me too.

sl27257’s picture

Patch #7 is RTBC according to me!

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/views/views.theme.inc
@@ -664,19 +664,21 @@ function template_preprocess_views_view_table(&$variables) {
+  if (!empty($handler->options['summary']) || !empty($handler->options['description'])) {
+    $variables['summary_element'] = [
+      '#type' => 'details',
+      '#title' => $handler->options['summary'],
+      // To ensure that the description is properly escaped during rendering,
+      // use an 'inline_template' to let Twig do its magic, instead of 'markup'.
+      'description' => [
+        '#type' => 'inline_template',
+        '#template' => '{{ description }}',
+        '#context' => [
+          'description' => $handler->options['description'],
+        ],
       ],
-    ],
-  ];
+    ];
+  }
   $variables['caption_needed'] |= !empty($variables['summary']) || !empty($variables['description']);

Can move the $variables['caption_needed'] assignment into the if and reduce complexity and type changes by doing:
$variables['caption_needed'] = TRUE;

See https://3v4l.org/rIGLZ

ravi.shankar’s picture

Status: Needs work » Needs review
StatusFileSize
new10.45 KB
new648 bytes

Here I have addressed comment #18.

alexpott’s picture

Status: Needs review » Needs work
+++ b/core/modules/views/views.theme.inc
@@ -678,8 +678,8 @@ function template_preprocess_views_view_table(&$variables) {
+    $variables['caption_needed'] |= !empty($variables['summary']) || !empty($variables['description']);

Can be $variables['caption_needed'] = TRUE; now. Then we preserve variable type and have less complexity.

ravi.shankar’s picture

Status: Needs work » Needs review
StatusFileSize
new10.38 KB
new505 bytes

I have addressed comment #20.

The last submitted patch, 19: 3149930-19.patch, failed testing. View results

alexpott’s picture

Status: Needs review » Needs work

@ravi.shankar there's also some other unexpected change in #21 some path alias stuff.

lendude’s picture

Status: Needs work » Needs review
StatusFileSize
new485 bytes
new2.52 KB

Here we go, interdiff is against #7

dww’s picture

Status: Needs review » Reviewed & tested by the community

#24 correctly addresses #18. Back to RTBC.

Thanks,
-Derek

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 5bd974ae17 to 9.1.x and 16ddcd41a6 to 9.0.x and 582584e499 to 8.9.x. Thanks!

  • alexpott committed 5bd974a on 9.1.x
    Issue #3149930 by Lendude, ravi.shankar, Bobík, dww, joaomachado,...

  • alexpott committed 16ddcd4 on 9.0.x
    Issue #3149930 by Lendude, ravi.shankar, Bobík, dww, joaomachado,...

  • alexpott committed 582584e on 8.9.x
    Issue #3149930 by Lendude, ravi.shankar, Bobík, dww, joaomachado,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.