Entity browser enhancements should only be executed once

Created on 6 October 2023, over 1 year ago

Problem/Motivation

This module enhances entity browser forms with its own JS using Drupal's JS behaviors API. This code can be invoked many times, especially on sites that use Bigpipe / Dynamic Page Cache. These modules cause Drupal behaviors to be executed multiple times, but with different contexts passed in.

Since this module adds click handlers to checkboxes in the entity browser selection form, if the behaviors are executed an even amount of times (2x, 4x, 6x, etc), the click handler registered by this module essentially cancels itself out, and the checkbox becomes impossible to click in the entity browser.

Steps to reproduce

I personally only encountered this after testing an upgrade from Drupal 9.5 to 10.1, so something in the Drupal upgrade, combined with my set of enabled modules (Bigpipe and Dynamic Page Cache?) is causing an extra execution of Drupal JS behaviors.

Proposed resolution

The once JS library should be used to ensure that the Backbone JS enhancements this module adds to Entity Browsers are only added one time. This is why the library exists and is commonly used in Drupal JS behaviors.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

5.0

Component

Code

Created by

🇺🇸United States bkosborne New Jersey, USA

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