Skip to content
Snippets Groups Projects
Unverified Commit 5ca9f5d8 authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #2738547 by smustgrave, mehul.gada, lauriii, sahil.goyal, larowlan,...

Issue #2738547 by smustgrave, mehul.gada, lauriii, sahil.goyal, larowlan, BarisW, xjm: Contextual Links do not respect parameters in the destination
parent 7c9a05d8
No related branches found
No related tags found
16 merge requests!8394[warning] array_flip(): Can only flip STRING and INTEGER values, when saving a non-revisionable custom content entity,!7780issue 3443822: fix for 'No route found for the specified format html. Supported formats: json, xml.',!5013Issue #3071143: Table Render Array Example Is Incorrect,!4848Issue #1566662: Update module should send notifications on Thursdays,!4792Issue #2230689: Remove redundant "Italic" style,!4220Issue #3368223: Link field > Access to internal links is not checked on display.,!3884Issue #3356842,!3870Issue #3087868,!3812Draft: Issue #3339373 by alexpott, andypost, mondrake:...,!3686Issue #3219967 against 9.5.x,!3683Issue #2939397: Clearing AliasManager cache with root path raises warning,!3543Issue #3344259: Allow ajax dialog to have focus configurable,!2205Quote all names in the regions section.,!1459Issue #3087632: menu_name max length is too long,!866Issue #2845319: The highlighting of the 'Home' menu-link does not respect query strings and fragment identifiers,!204Issue #3040556: It is not possible to react to an entity being duplicated
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
// Set the destination parameter on each of the contextual links. // Set the destination parameter on each of the contextual links.
const destination = `destination=${Drupal.encodePath( 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 () { $contextual.find('.contextual-links a').each(function () {
const url = this.getAttribute('href'); const url = this.getAttribute('href');
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
var $region = $contextual.closest('.contextual-region'); var $region = $contextual.closest('.contextual-region');
var contextual = Drupal.contextual; var contextual = Drupal.contextual;
$contextual.html(html).addClass('contextual').prepend(Drupal.theme('contextualTrigger')); $contextual.html(html).addClass('contextual').prepend(Drupal.theme('contextualTrigger'));
var destination = "destination=".concat(Drupal.encodePath(Drupal.url(drupalSettings.path.currentPath))); var destination = "destination=".concat(Drupal.encodePath(Drupal.url(drupalSettings.path.currentPath + window.location.search)));
$contextual.find('.contextual-links a').each(function () { $contextual.find('.contextual-links a').each(function () {
var url = this.getAttribute('href'); var url = this.getAttribute('href');
var glue = url.indexOf('?') === -1 ? '?' : '&'; var glue = url.indexOf('?') === -1 ? '?' : '&';
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Drupal\Tests\contextual\FunctionalJavascript; namespace Drupal\Tests\contextual\FunctionalJavascript;
use Drupal\Core\Url;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase; use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\user\Entity\Role; use Drupal\user\Entity\Role;
...@@ -114,4 +115,20 @@ public function testContextualLinksDestination() { ...@@ -114,4 +115,20 @@ public function testContextualLinksDestination() {
$this->assertEquals("destination=$expected_destination_value", $contextual_link_url_parsed['query']); $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']);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment