Skip to content
Snippets Groups Projects
Commit 8f0ea210 authored by Nick Veenhof's avatar Nick Veenhof Committed by Joris Vercammen
Browse files

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
No related branches found
No related tags found
No related merge requests found
......@@ -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'],
],
],
];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment