Commit 47d0aa0e authored by catch's avatar catch
Browse files

Issue #3190261 by danflanagan8, doostinharrell, phenaproxima, larowlan,...

Issue #3190261 by danflanagan8, doostinharrell, phenaproxima, larowlan, paulocs: MediaLibraryWidget can trigger an AJAX error if all media types can be referenced

(cherry picked from commit 458aa2cb)
parent 5cd38822
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -305,7 +305,8 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
    $element += [
      '#type' => 'fieldset',
      '#cardinality' => $this->fieldDefinition->getFieldStorageDefinition()->getCardinality(),
      '#target_bundles' => $settings['target_bundles'] ?? FALSE,
      // If no target bundles are specified, all target bundles are allowed.
      '#target_bundles' => $settings['target_bundles'] ?? [],
      '#attributes' => [
        'id' => $wrapper_id,
        'class' => ['js-media-library-widget'],
+6 −1
Original line number Diff line number Diff line
@@ -140,7 +140,12 @@ public function testWidget() {
    $this->assertTrue($menu->hasLink('Type Three'));
    $this->assertTrue($menu->hasLink('Type Four'));
    $this->assertTrue($menu->hasLink('Type Five'));
    $assert_session->elementExists('css', '.ui-dialog-titlebar-close')->click();

    // Insert media to test validation with null target_bundles.
    $this->switchToMediaType('One');
    $this->assertNotEmpty($assert_session->waitForText('Showing Type One media.'));
    $this->selectMediaItem(0);
    $this->pressInsertSelected('Added one media item.');

    // Assert that the media type menu is not available when only 1 type is
    // configured for the field.