summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLauri Eskola <lauri.eskola@acquia.com>2023-02-20 15:31:12 +0200
committerLauri Eskola <lauri.eskola@acquia.com>2023-02-20 15:31:12 +0200
commit4a0272e3506a140bfc5bb9777812dcac3bd9d7ee (patch)
tree0b19428afd727c80086ecea0a6dd193a8378e64e
parent7de47b04ecf189c3cc66711e78d27da3640d36c3 (diff)
downloaddrupal-4a0272e3506a140bfc5bb9777812dcac3bd9d7ee.tar.gz
drupal-4a0272e3506a140bfc5bb9777812dcac3bd9d7ee.zip
Issue #2738547 by smustgrave, mehul.gada, sahil.goyal, larowlan, BarisW, xjm: Contextual Links do not respect parameters in the destination
-rw-r--r--core/modules/contextual/js/contextual.js2
-rw-r--r--core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinksTest.php17
2 files changed, 18 insertions, 1 deletions
diff --git a/core/modules/contextual/js/contextual.js b/core/modules/contextual/js/contextual.js
index b5fe7d094fb..90b0d9056a9 100644
--- a/core/modules/contextual/js/contextual.js
+++ b/core/modules/contextual/js/contextual.js
@@ -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');
diff --git a/core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinksTest.php b/core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinksTest.php
index 726df7253c4..8bcc8a30159 100644
--- a/core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinksTest.php
+++ b/core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinksTest.php
@@ -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 @@ class ContextualLinksTest extends WebDriverTestBase {
$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']);
+ }
+
}