Problem/Motivation

When I have two different image media types, I'm no longer able to switch between them inside the media library modal.

Steps to reproduce

  • Create two different media types
  • Create a content type with a media entity reference field
  • Use Media library widget and allow at least two different media types
  • Enable aggregation for JS
  • Create a new node with the above content type
  • Click "Add Media"
  • Try and switch between the tabs to select another media type

Proposed resolution

As a workaround, I can exclude js/media_library.ui.js to get it working again:

js/media_library.ui.js: {preprocess: false}

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

phma created an issue. See original summary.

phma’s picture

Title: Switching between media library tabs when js aggregation is on » Switching between media library tabs when JS aggregation is on
cilefen’s picture

phma’s picture

Status: Active » Closed (cannot reproduce)

I wasn't able to reproduce the issue on a clean installation.

It seems to be a racing condition which prevents the JS from loading in time for Drupal behaviours to be attached properly in our setup. I've excluded the particular JS library in a custom module as a workaround.

/**
 * Implements hook_js_alter().
 */
  if (!empty($javascript['core/modules/media_library/js/media_library.ui.js'])) {
    $javascript['core/modules/media_library/js/media_library.ui.js']['preprocess'] = FALSE;
  }