Error in Entity Browser Modal: Uncaught TypeError and Incorrect Modal Sizing after Upgrade

Created on 5 February 2025, 2 months ago

Problem/Motivation

When trying to use the Entity Browser module on an Entity reference widget that references a media bundle of type Video, an error occurs in the `entity_browser.modal.js` file: "Uncaught TypeError: Cannot read properties of undefined (reading 'prototype')". Additionally, the modal does not display at the size configured in the General settings (Width of the modal) as it is being calculated with `height: auto; width: auto;`.

Steps to reproduce

1. Upgrade PHP to version 8.3.8.
2. Upgrade Drupal to version 10.4.1.
3. Upgrade the Entity Browser module to version 2.12.0.
4. Create an Entity Browser widget that references a media bundle of Video.
5. Attempt to select a video from the widget.
6. Observe that an error occurs in the console and the modal does not respect the size configured in the general settings.

Expected behavior

The modal should open at the size specified in the General settings of the Entity Browser and should not generate any errors in the console.

Actual behavior

The modal opens with incorrect dimensions (`height: auto; width: auto;`) and generates an error in the console: "Uncaught TypeError: Cannot read properties of undefined (reading 'prototype')".

Environment

- PHP: 8.3.8
- Drupal: 10.4.1
- Entity Browser: 2.12.0
- Previous versions: PHP 8.1, Drupal 10.2, Entity Browser 2.10.0

🐛 Bug report
Status

Active

Version

2.12

Component

Widget plugins

Created by

🇨🇴Colombia davidlfg

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

Comments & Activities

  • Issue created by @davidlfg
  • 🇨🇴Colombia davidlfg

    I was able to resolve the issue by adding a dependency to the modal in the `entity_browser.libraries.yml` file. Specifically, I included the following line:

    dependencies:

    +      - core/drupal.dialog.ajax
    

    This adjustment ensures that the modal works correctly and prevents the Uncaught TypeError from occurring.

    To help others facing the same issue, I am sharing a patch for the module with this adjustment. Here is the patch file

Production build 0.71.5 2024