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
...@@ -305,7 +305,8 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen ...@@ -305,7 +305,8 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
$element += [ $element += [
'#type' => 'fieldset', '#type' => 'fieldset',
'#cardinality' => $this->fieldDefinition->getFieldStorageDefinition()->getCardinality(), '#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' => [ '#attributes' => [
'id' => $wrapper_id, 'id' => $wrapper_id,
'class' => ['js-media-library-widget'], 'class' => ['js-media-library-widget'],
......
...@@ -140,7 +140,12 @@ public function testWidget() { ...@@ -140,7 +140,12 @@ public function testWidget() {
$this->assertTrue($menu->hasLink('Type Three')); $this->assertTrue($menu->hasLink('Type Three'));
$this->assertTrue($menu->hasLink('Type Four')); $this->assertTrue($menu->hasLink('Type Four'));
$this->assertTrue($menu->hasLink('Type Five')); $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 // Assert that the media type menu is not available when only 1 type is
// configured for the field. // configured for the field.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment