Commit 12c31093 authored by larowlan's avatar larowlan

Issue #2707879 by hctom, Sam152, grahl, reekris, casey, gngn, Noemi, dawehner,...

Issue #2707879 by hctom, Sam152, grahl, reekris, casey, gngn, Noemi, dawehner, jherencia: Contextual Links do not respect pathPrefix
parent 6c19c087
......@@ -99,7 +99,7 @@
// Set the destination parameter on each of the contextual links.
const destination = `destination=${Drupal.encodePath(
drupalSettings.path.currentPath,
Drupal.url(drupalSettings.path.currentPath),
)}`;
$contextual.find('.contextual-links a').each(function() {
const url = this.getAttribute('href');
......
......@@ -55,7 +55,7 @@
$contextual.html(html).addClass('contextual').prepend(Drupal.theme('contextualTrigger'));
var destination = 'destination=' + Drupal.encodePath(drupalSettings.path.currentPath);
var destination = 'destination=' + Drupal.encodePath(Drupal.url(drupalSettings.path.currentPath));
$contextual.find('.contextual-links a').each(function () {
var url = this.getAttribute('href');
var glue = url.indexOf('?') === -1 ? '?' : '&';
......
......@@ -92,4 +92,19 @@ public function testContextualLinksClick() {
$this->assertSession()->pageTextContains('Everything is contextual!');
}
/**
* Test the contextual links destination.
*/
public function testContextualLinksDestination() {
$this->grantPermissions(Role::load(Role::AUTHENTICATED_ID), [
'access contextual links',
'administer blocks',
]);
$this->drupalGet('user');
$this->assertSession()->waitForElement('css', '.contextual button');
$expected_destination_value = (string) $this->loggedInUser->toUrl()->toString();
$contextual_link_url_parsed = parse_url($this->getSession()->getPage()->findLink('Configure block')->getAttribute('href'));
$this->assertEquals("destination=$expected_destination_value", $contextual_link_url_parsed['query']);
}
}
......@@ -145,7 +145,8 @@ public function testCustomBlockLinks() {
$href = array_search('Quick edit', $link_labels);
$this->assertEquals('', $href);
$href = array_search('Quick edit settings', $link_labels);
$this->assertTrue(strstr($href, '/admin/structure/block/manage/custom/settings-tray?destination=user/2') !== FALSE);
$destination = (string) $this->loggedInUser->toUrl()->toString();
$this->assertTrue(strstr($href, "/admin/structure/block/manage/custom/settings-tray?destination=$destination") !== FALSE);
}
/**
......
......@@ -69,7 +69,8 @@ protected function doTestBlocks($theme, $block_plugin, $new_page_text, $element_
$link = $web_assert->waitForElement('css', "$block_selector .contextual-links li a");
$this->assertEquals('Quick edit', $link->getHtml(), "'Quick edit' is the first contextual link for the block.");
$this->assertContains("/admin/structure/block/manage/$block_id/settings-tray?destination=user/2", $link->getAttribute('href'));
$destination = (string) $this->loggedInUser->toUrl()->toString();
$this->assertContains("/admin/structure/block/manage/$block_id/settings-tray?destination=$destination", $link->getAttribute('href'));
if (isset($toolbar_item)) {
// Check that you can open a toolbar tray and it will be closed after
......
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