Problem/Motivation

The AJAX request /facets-block-ajax returns add_js command to inject already loaded Javascript files due to the new request created and push to request stack in FacetBlockAjaxController.

The AjaxResponseAttachmentsProcessor in buildAttachmentsCommands have $ajax_page_state = $request->get('ajax_page_state'); to NULL value, and means the code below does not set properly the already loaded library :

$assets->setLibraries($attachments['library'] ?? [])
      ->setAlreadyLoadedLibraries(isset($ajax_page_state['libraries']) ? explode(',', $ajax_page_state['libraries']) : [])
      ->setSettings($attachments['drupalSettings'] ?? []);

Steps to reproduce

Proposed resolution

Inject if exists the ajax_page_state to the new request :

    // Add ajax_page_state to the new request if set.
    if ($request->request->has('ajax_page_state')) {
      $new_request->request->set('ajax_page_state', $request->request->all('ajax_page_state'));
    }
    elseif ($request->query->has('ajax_page_state')) {
      $new_request->query->set('ajax_page_state', $request->query->all('ajax_page_state'));
    }

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork facets-3466566

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

xavier.masson created an issue. See original summary.

elc’s picture

Status: Active » Reviewed & tested by the community
Parent issue: » #3075378: [META] Overview of Facets + Ajax issues
StatusFileSize
new1.18 KB

Adding customised patch for adding after #3052574-254: Facets with AJAX not working in most of situations.

This is the only way to get my facets working with D10.3 again.

joao.ramos.costa’s picture

Works smoothly,
Tkx @elc.

+1

renrhaf’s picture

+1

p-neyens’s picture

+1

talisa1987’s picture

#3 Works for me. Thank you!

sivaji_ganesh_jojodae’s picture

Looking forward to the release.