- Issue created by @Anybody
- 🇧🇪Belgium RandalV
I'm also experiencing this issue in a new project of ours using Facets 3.0.0-beta4, exactly as described above.
On the view page itself, everything is fine. Anywhere else, all the facets are empty :(
I'll see if I can find anything, haven't had the time yet to debug.
- 🇧🇪Belgium RandalV
I haven't got the time to fully debug this in facets itself, but in my case it was solvable by rendering it in a custom block like below.
I had to render in a custom block anyway because I wanted to add extra items before and after the exposed filters, so this was a quick fix for me./** @var \Drupal\views\Plugin\Block\ViewsExposedFilterBlock $plugin_block */ $plugin_block = $this->blockManager->createInstance('views_exposed_filter_block:events-overview'); // Make sure the facets are populated. $view = $plugin_block->getViewExecutable(); $view->preExecute(); $view->execute(); return [ // ... 'filters' => $plugin_block->build(), // ... ];
- First commit to issue fork.
- 🇫🇷France mattlc
Drupal\ayout_builder\EventSubscriber\BlockComponentRenderArray directly calls "build()" method and do not call hook_block_build_alter. So in layout builder context, view may not have been executed (if view results block is not a component before exposed form block).
My context :
I have same issue using a view with one block for exposed filters and one block for results.
The blocks are set in a page via page_manager using layout builder with 2 columns section.Something I noticed is that the bug depends on how the blocks are organized in the page :
Case 1 :
- column 1 : exposed filters block
- column 2 : results block
=> Facets are not displayedCase 2 :
- column 1 : results block
- column 2 : exposed filters block
=> Facets are well displayedIn both cases, facets_exposed_filters_block_build_alter is never called.
Adding an event subscriber that listens "section_component.build.render_array" solved the issue.
I tried to not add any dependency to layout builder module this is why I use event name as String and Event Class. - Merge request !327Ensure that view is executed in layout builder context to prevent empty facets → (Open) created by mattlc