Skip to content

Commit

Permalink
Issue #3149930 by Lendude, ravi.shankar, Bobík, dww, joaomachado, ale…
Browse files Browse the repository at this point in the history
…xpott, lauriii: Views table settings exposes "Details" field even when empty

(cherry picked from commit 5bd974ae17b914a9c4563d7077f721bbff2df44d)
  • Loading branch information
alexpott committed Jul 6, 2020
1 parent aad10aa commit 69937f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
2 changes: 2 additions & 0 deletions modules/views/tests/src/Functional/Plugin/StyleTableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ public function testGrouping() {

// Ensure that we don't find the caption containing unsafe markup.
$this->assertNoRaw($unsafe_markup, "Didn't find caption containing unsafe markup.");
// Ensure that the summary isn't shown.
$this->assertEmpty($this->xpath('//caption/details'));

// Ensure that all expected captions are found.
foreach ($expected_captions as $raw_caption) {
Expand Down
28 changes: 15 additions & 13 deletions modules/views/views.theme.inc
Original file line number Diff line number Diff line change
Expand Up @@ -664,20 +664,22 @@ function template_preprocess_views_view_table(&$variables) {
// variables, although core templates now all use 'summary_element' instead.
$variables['summary'] = $handler->options['summary'];
$variables['description'] = $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'],
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']);
];
$variables['caption_needed'] = TRUE;
}

$variables['responsive'] = FALSE;
// If the table has headers and it should react responsively to columns hidden
Expand Down

0 comments on commit 69937f4

Please sign in to comment.