From 55663b5986bb310c2ae6a11636f84a94833cd7fb Mon Sep 17 00:00:00 2001
From: webchick <drupal@webchick.net>
Date: Fri, 16 Aug 2019 09:00:09 -0700
Subject: [PATCH] Issue #3075443 by oknate, Wim Leers, seanB: Follow-up for
 #2994699: Cardinality should be 1 for inserting embedded media

---
 .../src/Plugin/CKEditorPlugin/DrupalMediaLibrary.php            | 2 +-
 .../tests/src/FunctionalJavascript/CKEditorIntegrationTest.php  | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/core/modules/media_library/src/Plugin/CKEditorPlugin/DrupalMediaLibrary.php b/core/modules/media_library/src/Plugin/CKEditorPlugin/DrupalMediaLibrary.php
index 74d81af95c10..44aadf54087c 100644
--- a/core/modules/media_library/src/Plugin/CKEditorPlugin/DrupalMediaLibrary.php
+++ b/core/modules/media_library/src/Plugin/CKEditorPlugin/DrupalMediaLibrary.php
@@ -125,7 +125,7 @@ public function getConfig(Editor $editor) {
       'media_library.opener.editor',
       $media_type_ids,
       reset($media_type_ids),
-      -1,
+      1,
       ['filter_format_id' => $editor->getFilterFormat()->id()]
     );
 
diff --git a/core/modules/media_library/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php b/core/modules/media_library/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
index d6d3270dba91..3daea82dcd3f 100644
--- a/core/modules/media_library/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
+++ b/core/modules/media_library/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
@@ -164,7 +164,9 @@ public function testButton() {
       $this->assertSame($expected_tab_order[$key], $tab->getText());
     }
 
+    $assert_session->pageTextContains('0 of 1 item selected');
     $assert_session->elementExists('css', '.media-library-item')->click();
+    $assert_session->pageTextContains('1 of 1 item selected');
     $assert_session->elementExists('css', 'button.media-library-select.button.button--primary')->click();
     $this->assignNameToCkeditorIframe();
     $this->getSession()->switchToIFrame('ckeditor');
-- 
GitLab