diff --git a/core/modules/system/tests/fixtures/HtaccessTest/access_test.module~ b/core/modules/system/tests/fixtures/HtaccessTest/access_test.module~ old mode 100644 new mode 100755 diff --git a/core/modules/system/tests/fixtures/HtaccessTest/access_test.php~ b/core/modules/system/tests/fixtures/HtaccessTest/access_test.php~ old mode 100644 new mode 100755 diff --git a/core/modules/views_ui/js/views_ui.listing.js b/core/modules/views_ui/js/views_ui.listing.js index 7d19cd4..1daab04 100644 --- a/core/modules/views_ui/js/views_ui.listing.js +++ b/core/modules/views_ui/js/views_ui.listing.js @@ -51,4 +51,37 @@ } }; + + // When a view is enabled/disabled, this variable will hold it's machine name. + // It is used in the behavior to focus on the first dropbutton link of this + // view's row. + var changedView = ''; + + /** + * Handles focus after Ajax update. + * + * @type {Drupal~behavior} + * + * @prop {Drupal~behaviorAttach} attach + * Listen to disable events on views listing page to keep focus in context. + */ + Drupal.behaviors.viewsChangeFocus = { + attach: function (context) { + // Enable a view, keep the machine name around so that the next round of + // Drupal.behaviorAttach() focuses it. + $(context).find('[data-drupal-view-id] .use-ajax').once('viewsUiListFocus') + .on('click', function (event) { + // Store the machine name of the view to focus after ajax update. + changedView = $(event.target).closest('tr').attr('data-drupal-view-id'); + }); + + // A view has been enabled/disabled, focus the first dropbutton link. + if (changedView && changedView !== '') { + $('[data-drupal-view-id="' + changedView + '"]') + .find('.dropbutton a').eq(0).trigger('focus'); + changedView = ''; + } + } + }; + }(jQuery, Drupal)); diff --git a/core/modules/views_ui/src/ViewListBuilder.php b/core/modules/views_ui/src/ViewListBuilder.php index 112e1c4..3748bfc 100644 --- a/core/modules/views_ui/src/ViewListBuilder.php +++ b/core/modules/views_ui/src/ViewListBuilder.php @@ -117,6 +117,7 @@ public function buildRow(EntityInterface $view) { ), 'title' => $this->t('Machine name: @name', array('@name' => $view->id())), 'class' => array($view->status() ? 'views-ui-list-enabled' : 'views-ui-list-disabled'), + 'data-drupal-view-id' => $view->id(), ); } diff --git a/core/modules/views_ui/tests/src/FunctionalJavascript/ViewsListingTest.php b/core/modules/views_ui/tests/src/FunctionalJavascript/ViewsListingTest.php index c39db77..23769d8 100644 --- a/core/modules/views_ui/tests/src/FunctionalJavascript/ViewsListingTest.php +++ b/core/modules/views_ui/tests/src/FunctionalJavascript/ViewsListingTest.php @@ -88,6 +88,7 @@ public function testFilterViewsListing() { // Disable a View and see if it moves to the disabled listing. $enabled_view = $page->find('css', 'tr.views-ui-list-enabled'); + $enabled_view_id = $enabled_view->getAttribute('data-drupal-view-id'); // Open the dropdown with additional actions. $enabled_view->find('css', 'li.dropbutton-toggle button')->click(); $disable_button = $enabled_view->find('css', 'li.disable.dropbutton-action a'); @@ -105,6 +106,11 @@ public function testFilterViewsListing() { // Test that one enabled View has been moved to the disabled list. $this->assertCount(5, $enabled_rows); $this->assertCount(3, $disabled_rows); + + // Test that the keyboard focus is on the dropdown button of the View we + // just disabled. + $this->assertTrue($this->getSession()->evaluateScript("jQuery(document.activeElement).parent().is('li.disable.dropbutton-action')")); + $this->assertTrue($this->getSession()->evaluateScript("jQuery(document.activeElement).parents('tr.views-ui-list-disabled').data('drupal-view-id') == '$enabled_view_id'")); } /**