Verified Commit 205d4bfb authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3424746 by camille.davis@civicactions.com, mgifford, smustgrave,...

Issue #3424746 by camille.davis@civicactions.com, mgifford, smustgrave, rkoller: "Local Tasks" behaves as navigation bar but uses "tab" language
parent a99ed6d2
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@
 * customized by user themes.
 */

use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Url;
use Drupal\Component\Serialization\Json;
use Drupal\Component\Utility\Crypt;
@@ -1908,10 +1907,6 @@ function template_preprocess_menu_local_task(&$variables) {

  if (!empty($variables['element']['#active'])) {
    $variables['is_active'] = TRUE;

    // Add text to indicate active tab for non-visual users.
    $active = new FormattableMarkup('<span class="visually-hidden">@label</span>', ['@label' => t('(active tab)')]);
    $link_text = t('@local-task-title@active', ['@local-task-title' => $link_text, '@active' => $active]);
  }

  $link['localized_options']['set_active_class'] = TRUE;
+1 −1
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ public function testBlockNotInHiddenRegion() {

    // Ensure that "block_test_theme" is set as the default theme.
    $this->drupalGet('admin/structure/block');
    $this->assertSession()->pageTextContains('Block test theme(active tab)');
    $this->assertSession()->pageTextContains('Block test theme');

    // Ensure that the search form block is displayed.
    $this->drupalGet('');
+1 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ public function testNonDefaultBlockAdmin() {
    \Drupal::service('theme_installer')->install([$new_theme]);
    // Ensure that the Olivero tab is shown.
    $this->drupalGet('admin/structure/block/list/' . $new_theme);
    $this->assertSession()->pageTextContains('Olivero(active tab)');
    $this->assertSession()->pageTextContains('Olivero');
  }

}
+1 −1
Original line number Diff line number Diff line
@@ -91,7 +91,7 @@ public function testNodeEdit() {

    // Check that the title and body fields are displayed with the correct values.
    // @todo Ideally assertLink would support HTML, but it doesn't.
    $this->assertSession()->responseContains('Edit<span class="visually-hidden">(active tab)</span>');
    $this->assertSession()->responseContains('Edit');
    $this->assertSession()->fieldValueEquals($title_key, $edit[$title_key]);
    $this->assertSession()->fieldValueEquals($body_key, $edit[$body_key]);

+8 −8
Original line number Diff line number Diff line
@@ -133,7 +133,7 @@ public function testPluginLocalTask() {

    // Ensure the view tab is active.
    $this->assertSession()->elementsCount('xpath', '//ul[contains(@class, "tabs")]//li[contains(@class, "active")]/a', 1);
    $this->assertSession()->elementTextEquals('xpath', '//ul[contains(@class, "tabs")]//li[contains(@class, "active")]/a', 'View(active tab)');
    $this->assertSession()->elementTextEquals('xpath', '//ul[contains(@class, "tabs")]//li[contains(@class, "active")]/a', 'View');

    // Verify that local tasks in the second level appear.
    $sub_tasks = [
@@ -147,7 +147,7 @@ public function testPluginLocalTask() {
    $this->assertLocalTasks($sub_tasks, 1);

    $this->assertSession()->elementsCount('xpath', '//ul[contains(@class, "tabs")]//li[contains(@class, "active")]/a', 1);
    $this->assertSession()->elementTextEquals('xpath', '//ul[contains(@class, "tabs")]//li[contains(@class, "active")]/a', 'Settings(active tab)');
    $this->assertSession()->elementTextEquals('xpath', '//ul[contains(@class, "tabs")]//li[contains(@class, "active")]/a', 'Settings');

    $this->drupalGet(Url::fromRoute('menu_test.local_task_test_tasks_settings_sub1'));
    $this->assertLocalTasks($sub_tasks, 1);
@@ -155,8 +155,8 @@ public function testPluginLocalTask() {
    $xpath = '//ul[contains(@class, "tabs")]//a[contains(@class, "active")]';
    $this->assertSession()->elementsCount('xpath', $xpath, 2);
    $links = $this->xpath($xpath);
    $this->assertEquals('Settings(active tab)', $links[0]->getText(), 'The settings tab is active.');
    $this->assertEquals('Dynamic title for TestTasksSettingsSub1(active tab)', $links[1]->getText(), 'The sub1 tab is active.');
    $this->assertEquals('Settings', $links[0]->getText(), 'The settings tab is active.');
    $this->assertEquals('Dynamic title for TestTasksSettingsSub1', $links[1]->getText(), 'The sub1 tab is active.');

    $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'kittens:ragdoll');
    $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'kittens:dwarf-cat');
@@ -166,8 +166,8 @@ public function testPluginLocalTask() {

    $result = $this->xpath('//ul[contains(@class, "tabs")]//li[contains(@class, "active")]');
    $this->assertCount(2, $result, 'There are tabs active on both levels.');
    $this->assertEquals('Settings(active tab)', $result[0]->getText(), 'The settings tab is active.');
    $this->assertEquals('Derive 1(active tab)', $result[1]->getText(), 'The derive1 tab is active.');
    $this->assertEquals('Settings', $result[0]->getText(), 'The settings tab is active.');
    $this->assertEquals('Derive 1', $result[1]->getText(), 'The derive1 tab is active.');

    // Ensures that the local tasks contains the proper 'provider key'
    $definitions = $this->container->get('plugin.manager.menu.local_task')->getDefinitions();
@@ -193,7 +193,7 @@ public function testPluginLocalTask() {
    $this->assertLocalTasks($tasks, 0);

    $this->assertSession()->elementsCount('xpath', '//ul[contains(@class, "tabs")]//li[contains(@class, "active")]', 1);
    $this->assertSession()->elementTextEquals('xpath', '//ul[contains(@class, "tabs")]//li[contains(@class, "active")]', 'upcasting sub1(active tab)');
    $this->assertSession()->elementTextEquals('xpath', '//ul[contains(@class, "tabs")]//li[contains(@class, "active")]', 'upcasting sub1');

    $this->drupalGet(Url::fromRoute('menu_test.local_task_test_upcasting_sub2', ['entity_test' => '1']));

@@ -204,7 +204,7 @@ public function testPluginLocalTask() {
    $this->assertLocalTasks($tasks, 0);

    $this->assertSession()->elementsCount('xpath', '//ul[contains(@class, "tabs")]//li[contains(@class, "active")]', 1);
    $this->assertSession()->elementTextEquals('xpath', '//ul[contains(@class, "tabs")]//li[contains(@class, "active")]', 'upcasting sub2(active tab)');
    $this->assertSession()->elementTextEquals('xpath', '//ul[contains(@class, "tabs")]//li[contains(@class, "active")]', 'upcasting sub2');
  }

  /**
Loading