When language-specific path prefixes are used on 8.0.6 and later (code seems unchanged including 8.2.x-dev) the destination parameter does not include them and they are removed.

Comments

grahl created an issue. See original summary.

grahl’s picture

The attached path includes the pathPrefix, I did not separately test this with a site without language prefixes, assuming that encodePath is fine with null values.

Related issue: https://www.drupal.org/node/2639822

dawehner’s picture

Could we use the Drupal.url method directly for it?

droplet’s picture

Status: Needs review » Needs work
Issue tags: +JavaScript

#3++

Drupal.url(drupalSettings.path.currentPath)

droplet’s picture

reekris’s picture

I'm experiencing the same issues in my current project. Here is a patch that uses Drupal.url which seems to work fine.

reekris’s picture

Status: Needs work » Needs review
dawehner’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

It would be nice to add some javascript test coverage to prove that things are working.

jherencia’s picture

Drupal.url does not encode the path, would it be better to do this?

--- a/core/modules/contextual/js/contextual.js
+++ b/core/modules/contextual/js/contextual.js
@@ -55,7 +55,7 @@
       .prepend(Drupal.theme('contextualTrigger'));

     // Set the destination parameter on each of the contextual links.
-    var destination = 'destination=' + Drupal.encodePath(drupalSettings.path.currentPath);
+    var destination = 'destination=' + Drupal.encodePath(Drupal.url(drupalSettings.path.currentPath));
Wim Leers’s picture

#10 is right.