Skip to content
Snippets Groups Projects
Commit 834c16c5 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 5d4a86bb
No related branches found
No related tags found
No related merge requests found
......@@ -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'],
......
......@@ -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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment