Commit 8f0ea210 authored by Nick_vh's avatar Nick_vh Committed by borisson_

Issue #2984465 by Nick_vh, akalam, borisson_, seanB, nedjo, ChristianAdamski,...

Issue #2984465 by Nick_vh, akalam, borisson_, seanB, nedjo, ChristianAdamski, estoyausente: Hide facets when it is configured to hide the block without losing support for bigpipe and ajax facets
parent 9f5221f3
......@@ -149,6 +149,12 @@ function facets_entity_presave(EntityInterface $entity) {
*/
function facets_preprocess_block(&$variables) {
if ($variables['configuration']['provider'] == 'facets') {
// Hide the block if it's empty.
if (!empty($variables['elements']['content'][0]['#attributes']['class']) && in_array('facet-hidden', $variables['elements']['content'][0]['#attributes']['class'])) {
// Add the Drupal class for hiding this for everyone, including screen
// readers. See hidden.module.css in the core system module.
$variables['attributes']['class'][] = 'hidden';
}
if (!empty($variables['derivative_plugin_id'])) {
$facet = Facet::load($variables['derivative_plugin_id']);
$variables['attributes']['class'][] = 'block-facet--' . Html::cleanCssIdentifier($facet->getWidget()['type']);
......
......@@ -350,7 +350,7 @@ class DefaultFacetManager {
'#type' => 'container',
'#attributes' => [
'data-drupal-facet-id' => $facet->id(),
'class' => ['facet-empty'],
'class' => ['facet-empty', 'facet-hidden'],
],
],
];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment