Commit b20aea60 authored by catch's avatar catch

Issue #1848940 by milanpavic, dawehner, nod_, helenasue, DuaelFr, Lendude,...

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
parent 323c56ca
......@@ -888,7 +888,7 @@
if (!focusChanged && this.element && !$(this.element).data('disable-refocus')) {
let target = false;
for (let n = elementParents.length - 1; !target && n > 0; n--) {
for (let n = elementParents.length - 1; !target && n >= 0; n--) {
target = document.querySelector(`[data-drupal-selector="${elementParents[n].getAttribute('data-drupal-selector')}"]`);
}
......
......@@ -420,7 +420,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
if (!focusChanged && this.element && !$(this.element).data('disable-refocus')) {
var target = false;
for (var n = elementParents.length - 1; !target && n > 0; n--) {
for (var n = elementParents.length - 1; !target && n >= 0; n--) {
target = document.querySelector('[data-drupal-selector="' + elementParents[n].getAttribute('data-drupal-selector') + '"]');
}
......
......@@ -178,6 +178,14 @@ public function getDefaultOperations(EntityInterface $entity) {
}
}
// 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;
}
......
......@@ -92,6 +92,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');
$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 @@ public function testFilterViewsListing() {
// 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()"));
}
/**
......
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