Issue #3149930 by Lendude, ravi.shankar, Bobík, dww, joaomachado, alexpott, lauriii: Views table settings exposes "Details" field even when empty
(cherry picked from commit 5bd974ae17
)
merge-requests/64/head
parent
d31a8c6341
commit
582584e499
|
@ -211,6 +211,8 @@ class StyleTableTest extends ViewTestBase {
|
||||||
|
|
||||||
// Ensure that we don't find the caption containing unsafe markup.
|
// Ensure that we don't find the caption containing unsafe markup.
|
||||||
$this->assertNoRaw($unsafe_markup, "Didn't find 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.
|
// Ensure that all expected captions are found.
|
||||||
foreach ($expected_captions as $raw_caption) {
|
foreach ($expected_captions as $raw_caption) {
|
||||||
|
|
|
@ -664,20 +664,22 @@ function template_preprocess_views_view_table(&$variables) {
|
||||||
// variables, although core templates now all use 'summary_element' instead.
|
// variables, although core templates now all use 'summary_element' instead.
|
||||||
$variables['summary'] = $handler->options['summary'];
|
$variables['summary'] = $handler->options['summary'];
|
||||||
$variables['description'] = $handler->options['description'];
|
$variables['description'] = $handler->options['description'];
|
||||||
$variables['summary_element'] = [
|
if (!empty($handler->options['summary']) || !empty($handler->options['description'])) {
|
||||||
'#type' => 'details',
|
$variables['summary_element'] = [
|
||||||
'#title' => $handler->options['summary'],
|
'#type' => 'details',
|
||||||
// To ensure that the description is properly escaped during rendering, use
|
'#title' => $handler->options['summary'],
|
||||||
// an 'inline_template' to let Twig do its magic, instead of 'markup'.
|
// To ensure that the description is properly escaped during rendering,
|
||||||
'description' => [
|
// use an 'inline_template' to let Twig do its magic, instead of 'markup'.
|
||||||
'#type' => 'inline_template',
|
'description' => [
|
||||||
'#template' => '{{ description }}',
|
'#type' => 'inline_template',
|
||||||
'#context' => [
|
'#template' => '{{ description }}',
|
||||||
'description' => $handler->options['description'],
|
'#context' => [
|
||||||
|
'description' => $handler->options['description'],
|
||||||
|
],
|
||||||
],
|
],
|
||||||
],
|
];
|
||||||
];
|
$variables['caption_needed'] = TRUE;
|
||||||
$variables['caption_needed'] |= !empty($variables['summary']) || !empty($variables['description']);
|
}
|
||||||
|
|
||||||
$variables['responsive'] = FALSE;
|
$variables['responsive'] = FALSE;
|
||||||
// If the table has headers and it should react responsively to columns hidden
|
// If the table has headers and it should react responsively to columns hidden
|
||||||
|
|
Loading…
Reference in New Issue