New $request created in FacetBlockAjaxController missing ajax_page_state

Created on 7 August 2024, 5 months ago

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

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇫🇷France xavier.masson Haute-Normandie

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024