Unverified Commit e72c868f authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #2738547 by smustgrave, mehul.gada, sahil.goyal, larowlan, BarisW, xjm:...

Issue #2738547 by smustgrave, mehul.gada, sahil.goyal, larowlan, BarisW, xjm: Contextual Links do not respect parameters in the destination

(cherry picked from commit 4a0272e3)
parent 157ebea1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@

    // Set the destination parameter on each of the contextual links.
    const destination = `destination=${Drupal.encodePath(
      Drupal.url(drupalSettings.path.currentPath),
      Drupal.url(drupalSettings.path.currentPath + window.location.search),
    )}`;
    $contextual.find('.contextual-links a').each(function () {
      const url = this.getAttribute('href');
+17 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Drupal\Tests\contextual\FunctionalJavascript;

use Drupal\Core\Url;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\user\Entity\Role;

@@ -117,4 +118,20 @@ public function testContextualLinksDestination() {
    $this->assertEquals("destination=$expected_destination_value", $contextual_link_url_parsed['query']);
  }

  /**
   * Tests the contextual links destination with query.
   */
  public function testContextualLinksDestinationWithQuery() {
    $this->grantPermissions(Role::load(Role::AUTHENTICATED_ID), [
      'access contextual links',
      'administer blocks',
    ]);

    $this->drupalGet('admin/structure/block', ['query' => ['foo' => 'bar']]);
    $this->assertSession()->waitForElement('css', '.contextual button');
    $expected_destination_value = Url::fromRoute('block.admin_display')->toString();
    $contextual_link_url_parsed = parse_url($this->getSession()->getPage()->findLink('Configure block')->getAttribute('href'));
    $this->assertEquals("destination=$expected_destination_value%3Ffoo%3Dbar", $contextual_link_url_parsed['query']);
  }

}