AJAX race condition when facet block is inside view header

Created on 16 February 2024, 4 months ago
Updated 20 February 2024, 4 months ago

Problem/Motivation

We have a view were we use the views_block_area module to place the facet block inside the view header.
This causes problems because the /views/ajax and /facets-block-ajax AJAX requests both update the same HTML.
If /views/ajax finishes first, it rewrites the blocks ID and then the replace command returned by /facets-block-ajax does not find the block to replace.
(This in turn makes Drupal.detachBehaviors() call the detach function of behaviors with context = document, which causes all sorts of problems.)

But in this scenario, we don't actually need to call /facets-block-ajax because /views/ajax already updates facets since they are inside the view.

Steps to reproduce

  1. Use views_block_area to place a facet block inside a view header.
  2. Enable AJAX on the view.
  3. Click on a facet link and inspect requests.
  4. Two AJAX requests are sent and their response both manipulate the same HTML.

Proposed resolution

facets-views-ajax.js should not send the request to /facets-block-ajax if the facet blocks are inside the view.

πŸ› Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡«πŸ‡·France prudloff Lille

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024