I have investigated some time to debug the issue, and there are two main problems:

  1. The components added by the Layout Builder do not have an id attribute. The javascript file facets-views-ajax.js needs the id to update the summary. The place where a javascript error appears on facet change because of the missing id attribute is js/facets-views-aja.js
    var facet_summary_wrapper_id = $('[data-drupal-facets-summary-id=' + settings.facets_views_ajax.facets_summary_ajax.facets_summary_id + ']').attr('id');
    
  2. The ajax controller can't find the block because it does not exist on the block storage in this case. The method which check for the summary block on ajax request is Controller\FacetBlockAjaxController::ajaxFacetBlockView

I checked for a similar issue, but I couldn't find it. That's why I am adding this one now. If there a know issue about it, please let me know. Any advice or notes would be beneficial. I plan to apply a fix and create a patch.

Comments

MPetkovFFW created an issue. See original summary.

matiasmiranda’s picture

I patched Facets with this https://www.drupal.org/project/facets/issues/3052574#comment-13541966

I'm using LayoutBuilder and the FacetSummary is updated correctly via ajax, but when you click on a pill to remove a facet it reloads the page instead of trigger an ajax callback..

Adding the FacetSummary block to LayoutBuilder fails due the missing id as you mentioned...

matiasmiranda’s picture

I added fixes to facet_summary here https://www.drupal.org/project/facets/issues/3052574#comment-13729259
Now it works properly on Layout Builder.

I think we can close this and follow up on #3052574

liam morland’s picture

Status: Active » Closed (duplicate)
Related issues: +#3052574: Facets with AJAX not working in most of situations

Closed based on #3.