summaryrefslogtreecommitdiffstats
path: root/core/modules/views_ui
diff options
context:
space:
mode:
authorNathaniel Catchpole2018-05-09 11:29:14 (GMT)
committerNathaniel Catchpole2018-05-09 11:29:14 (GMT)
commitb20aea605d0c10a0e58c0a1be4e6b0cef111c722 (patch)
tree87ae28fefc673fc79040ba887bf4098c3ad493e0 /core/modules/views_ui
parent323c56ca5c4e258fd47ac0d19ab992a195bb8970 (diff)
Issue #1848940 by milanpavic, dawehner, nod_, helenasue, DuaelFr, Lendude, AjitS, sdstyles, runeasgar, tim.plunkett: When enabling or disabling a View, don't move the cursor to the top of the page
Diffstat (limited to 'core/modules/views_ui')
-rw-r--r--core/modules/views_ui/src/ViewListBuilder.php8
-rw-r--r--core/modules/views_ui/tests/src/FunctionalJavascript/ViewsListingTest.php13
2 files changed, 21 insertions, 0 deletions
diff --git a/core/modules/views_ui/src/ViewListBuilder.php b/core/modules/views_ui/src/ViewListBuilder.php
index 628408e..c690aee 100644
--- a/core/modules/views_ui/src/ViewListBuilder.php
+++ b/core/modules/views_ui/src/ViewListBuilder.php
@@ -178,6 +178,14 @@ class ViewListBuilder extends ConfigEntityListBuilder {
}
}
+ // ajax.js focuses automatically on the data-drupal-selector element. When
+ // enabling the view again, focusing on the disable link doesn't work, as it
+ // is hidden. We assign data-drupal-selector to every link, so it focuses
+ // on the edit link.
+ foreach ($operations as &$operation) {
+ $operation['attributes']['data-drupal-selector'] = 'views-listing-' . $entity->id();
+ }
+
return $operations;
}
diff --git a/core/modules/views_ui/tests/src/FunctionalJavascript/ViewsListingTest.php b/core/modules/views_ui/tests/src/FunctionalJavascript/ViewsListingTest.php
index cab99bd..86d3b6e 100644
--- a/core/modules/views_ui/tests/src/FunctionalJavascript/ViewsListingTest.php
+++ b/core/modules/views_ui/tests/src/FunctionalJavascript/ViewsListingTest.php
@@ -92,6 +92,7 @@ class ViewsListingTest extends JavascriptTestBase {
// Disable a View and see if it moves to the disabled listing.
$enabled_view = $page->find('css', 'tr.views-ui-list-enabled');
+ $view_description = $enabled_view->find('css', '.views-ui-view-name h3')->getText();
// 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');
@@ -109,6 +110,18 @@ class ViewsListingTest extends JavascriptTestBase {
// Test that one enabled View has been moved to the disabled list.
$this->assertCount($enabled_views_count - 1, $enabled_rows);
$this->assertCount($disabled_views_count + 1, $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.enable.dropbutton-action')"));
+ $this->assertEquals($view_description, $this->getSession()->evaluateScript("jQuery(document.activeElement).parents('tr').find('h3').text()"));
+
+ // Enable the view again and ensure we have the focus on the edit button.
+ $this->getSession()->evaluateScript('jQuery(document.activeElement).click()');
+ $session->assertWaitOnAjaxRequest();
+
+ $this->assertTrue($this->getSession()->evaluateScript("jQuery(document.activeElement).parent().is('li.edit.dropbutton-action')"));
+ $this->assertEquals($view_description, $this->getSession()->evaluateScript("jQuery(document.activeElement).parents('tr').find('h3').text()"));
}
/**