diff --git a/core/modules/media_library/css/media_library.theme.css b/core/modules/media_library/css/media_library.theme.css index 9e651f8281..52d4799ed1 100644 --- a/core/modules/media_library/css/media_library.theme.css +++ b/core/modules/media_library/css/media_library.theme.css @@ -184,16 +184,6 @@ order: 1; } -.media-library-wrapper .media-library-view .button--primary { - position: absolute; - top: 0; - left: 0; /* LTR */ -} -[dir="rtl"] .media-library-wrapper .media-library-view .button--primary { - right: 0; - left: auto; -} - /* @todo Remove order and reorder the views header and filters via a views template in https://www.drupal.org/project/drupal/issues/3035994 */ .media-library-wrapper .media-library-view .view-content { @@ -220,14 +210,14 @@ .media-library-wrapper .views-display-link-widget { margin-right: 15px; - background: url(../../../misc/icons/333333/grid.svg) 0 0 no-repeat; /* LTR */ + background: url(../../../misc/icons/333333/grid.svg) left 0 no-repeat; /* LTR */ } [dir="rtl"] .media-library-wrapper .views-display-link-widget { background-position: right 0; } .media-library-wrapper .views-display-link-widget_table { - background: url(../../../misc/icons/333333/table.svg) 0 0 no-repeat; /* LTR */ + background: url(../../../misc/icons/333333/table.svg) left 0 no-repeat; /* LTR */ } [dir="rtl"] .media-library-wrapper .views-display-link-widget_table { background-position: right 0; diff --git a/core/modules/media_library/js/media_library.ui.es6.js b/core/modules/media_library/js/media_library.ui.es6.js index eee0979531..3ab1e3b02d 100644 --- a/core/modules/media_library/js/media_library.ui.es6.js +++ b/core/modules/media_library/js/media_library.ui.es6.js @@ -186,7 +186,7 @@ const success = ajaxObject.success; ajaxObject.success = function(response, status) { success.bind(this)(response, status); - // The AJAX link replace the whole view, including the clicked + // The AJAX link replaces the whole view, including the clicked // link. Move the focus back to the clicked link when the view is // replaced. $(`#${$link.attr('id')}`).focus(); diff --git a/core/modules/media_library/media_library.module b/core/modules/media_library/media_library.module index 81dd4e0434..1659e1ca0d 100644 --- a/core/modules/media_library/media_library.module +++ b/core/modules/media_library/media_library.module @@ -72,7 +72,8 @@ function media_library_preprocess_container(&$variables) { // load via AJAX. // @see Drupal.behaviors.MediaLibraryViewsDisplay // @see \Drupal\views\Element\View::preRenderViewElement() - if (isset($variables['element']['#view_id']) && $variables['element']['#view_id'] === 'media_library' && strpos($variables['element']['#display_id'], 'widget') === 0) { + $element = $variables['element']; + if (isset($element['#view_id'], $element['#display_id']) && $element['#view_id'] === 'media_library' && strpos($element['#display_id'], 'widget') === 0) { $variables['attributes']['id'] = 'media-library-view'; } } @@ -89,7 +90,7 @@ function media_library_link_alter(&$variables) { if ($is_view_display_link && $options['view']->id() === 'media_library' && strpos($options['view']->current_display, 'widget') === 0) { $options['attributes']['class'][] = 'js-media-library-view-display-link'; - // The AJAX link replace the whole view, including the clicked link. After + // The AJAX link replaces the whole view, including the clicked link. After // the page is updated with the new view, the focus needs to be returned to // the clicked link, so we add an ID to target the link. // @see Drupal.behaviors.MediaLibraryViewsDisplay diff --git a/core/modules/media_library/media_library.post_update.php b/core/modules/media_library/media_library.post_update.php index 8f999331a4..502418c6bc 100644 --- a/core/modules/media_library/media_library.post_update.php +++ b/core/modules/media_library/media_library.post_update.php @@ -37,7 +37,7 @@ function media_library_post_update_table_display() { $view = Views::getView('media_library'); if (!$view) { - return t('The media_library view could not be updated because it has been deleted. The media library module needs this view to display correctly. Uninstall and reinstall the module so the view will be re-created.'); + return t('The media_library view could not be updated because it has been deleted. The Media library module needs this view in order to work properly. Uninstall and reinstall the module so the view will be re-created.'); } // Override CSS classes to allow targeting grid displays. diff --git a/core/modules/media_library/src/Plugin/views/field/MediaLibrarySelectForm.php b/core/modules/media_library/src/Plugin/views/field/MediaLibrarySelectForm.php index ab2fe35bae..c2067660e8 100644 --- a/core/modules/media_library/src/Plugin/views/field/MediaLibrarySelectForm.php +++ b/core/modules/media_library/src/Plugin/views/field/MediaLibrarySelectForm.php @@ -53,7 +53,8 @@ public function viewsForm(array &$form, FormStateInterface $form_state) { 'class' => ['media-library-views-form', 'js-media-library-views-form'], ]; - // Add the view to the form state. + // Add the view to the form state so the opener ID can be fetched from the + // view request object in ::updateWidget(). $form_state->set('view', $this->view); // Render checkboxes for all rows. diff --git a/core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTest.php b/core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTest.php index eded7c347b..abeb660e33 100644 --- a/core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTest.php +++ b/core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTest.php @@ -300,16 +300,16 @@ public function testWidget() { $assert_session->assertWaitOnAjaxRequest(); $assert_session->elementExists('css', '.media-library-view .media-library-item--grid'); $assert_session->elementNotExists('css', '.media-library-view .media-library-item--table'); - $button_pane = $assert_session->elementExists('css', '.ui-dialog-buttonpane'); // Assert the 'Apply filter' button is not moved to the button pane. + $button_pane = $assert_session->elementExists('css', '.ui-dialog-buttonpane'); $assert_session->buttonExists('Select media', $button_pane); $assert_session->buttonNotExists('Apply filters', $button_pane); - $page->hasLink('Grid'); + $assert_session->linkExists('Grid'); $page->clickLink('Table'); // Assert the display change is correctly announced for screen readers. - $assert_session->waitForText('Loading table view.'); - $assert_session->waitForText('Changed to table view.'); - $assert_session->waitForElementVisible('css', '.media-library-view .media-library-item--table'); + $this->assertNotEmpty($assert_session->waitForText('Loading table view.')); + $this->assertNotEmpty($assert_session->waitForText('Changed to table view.')); + $this->assertNotEmpty($assert_session->waitForElementVisible('css', '.media-library-view .media-library-item--table')); $assert_session->elementNotExists('css', '.media-library-view .media-library-item--grid'); // Assert the 'Apply filter' button is not moved to the button pane. $assert_session->buttonExists('Select media', $button_pane); @@ -325,20 +325,20 @@ public function testWidget() { $assert_session->pageTextNotContains('Bear'); $assert_session->pageTextNotContains('Turtle'); $page->checkField('Select Dog'); - $page->hasLink('Table'); + $assert_session->linkExists('Table'); $page->clickLink('Grid'); // Assert the display change is correctly announced for screen readers. - $assert_session->waitForText('Loading grid view.'); - $assert_session->waitForText('Changed to grid view.'); - $assert_session->waitForElementVisible('css', '.media-library-view .media-library-item--grid'); + $this->assertNotEmpty($assert_session->waitForText('Loading grid view.')); + $this->assertNotEmpty($assert_session->waitForText('Changed to grid view.')); + $this->assertNotEmpty($assert_session->waitForElementVisible('css', '.media-library-view .media-library-item--grid')); $assert_session->elementNotExists('css', '.media-library-view .media-library-item--table'); // Assert the exposed filters are persisted when changing display. $this->assertSame('Dog', $page->findField('Name')->getValue()); $assert_session->pageTextContains('Dog'); $assert_session->pageTextNotContains('Bear'); $assert_session->pageTextNotContains('Turtle'); - $page->hasLink('Grid'); - $page->hasLink('Table'); + $assert_session->linkExists('Grid'); + $assert_session->linkExists('Table'); // Select the item. $assert_session->elementExists('css', '.ui-dialog-buttonpane')->pressButton('Select media'); $assert_session->assertWaitOnAjaxRequest();