When viewing an entity with an alias, the edit link sets the destination path using the system path, rather than the alias.
So after editing, the user is returned to the system path - e.g. node/1.
This is likely to be confusing and annoying for content editors.
For example, from a taxonomy term with the alias technologies/drupal, the edit link is taxonomy/term/11/edit?destination=taxonomy/term/11
| Comment | File | Size | Author |
|---|---|---|---|
| #44 | 2639822-44.patch | 1.15 KB | _utsavsharma |
| #44 | interdiff_34-44.txt | 1.15 KB | _utsavsharma |
| #42 | contextual-add-destination-alias-2639822-42.patch | 1.48 KB | phoang |
| #36 | After patch.png | 24.27 KB | mitthukumawat |
| #34 | contextual-add-destination-alias-2639822-34.patch | 1.39 KB | t-lo |
Comments
Comment #2
swentel commentedHmm, I think this is the same behavior as in D7.
Another way to see it is that a redirect should try to redirect to the aliased version of it, instead of putting it in the destination.
I'm guessing that's why there are modules like redirect/global redirect.
Comment #3
swentel commentedComment #4
malcomio commentedHaving dug into this further, the problem here is specific to contextual links - if the "Tabs" block appears, the edit link doesn't explicitly set the destination of the edit form, but just takes you to node/123/edit.
In both D7 and D8, If you go to node/123/edit and save, you are sent to the aliased path as expected.
In D8, when you're viewing the node on its own page, the edit link that is provided by contextual links includes the unaliased path in the destination query string.
Comment #5
malcomio commentedHmm, not so sure that contextual.module is the right component any more.
contextual.js gets the destination from drupalSettings.path.currentPath, which is set to the un-aliased path in system_js_settings_alter
Looks like currentPath is also used in toolbar and core/misc/active-link.js
Maybe it's better for contextual.js to get the destination from the browser rather than Drupal settings?
Comment #6
wim leersConfirmed. Great catch.
#2136507: Use client-side cache tags & caching to eliminate 1 HTTP requests/page for rendering Contextual Links introduced that behavior (to use
currentPathfromdrupalSettings). The subtle difference is that that means that we now use:whereas we used to use:
Therefore, I think we want to add something like
currentPathProcessed. Rough patch attached.Comment #7
dawehnerSo we have code executed on a lot of page requests, right? Let's see how much additional cost this needs.
Can we maybe move this to contextual module only? I could totally imagine that people turn off contextual module on production.
Comment #8
wim leersA single additional URL being generated needs profiling? Also note that this is merely reintroducing code that used to run anyway.
Also: I wonder what @nod_ thinks about using
window.location.pathname. I currently can't think of a reason not to use that. That'd make all this much simpler :) Thoughts? I feel like I'm forgetting about some crucial reason to not use this?Comment #9
malcomio commentedDigging through the git history of contextual.js it seems like it's been using drupalSettings to get the current path since #914382: Contextual links incompatible with render cache.
I don't know the history of the render cache issue, but I can't think of a reason why we can't just get the current URL via Javascript.
Comment #10
dawehnerI guess a reason why it was there is that people wanted to link to the path alias, even if you are on a non path alias page, which is, well, probably really helpful SEO optimization.
Comment #11
wim leers#10: contextual links are only for authenticated users. So I don't see how this can be related to SEO?
Comment #12
dawehnerI'm just guessing.
Comment #14
grahlI came to this issue in search of a problem with missing language path prefixes (e.g. '/fr/') since my editors were getting sent to '/node/123' instead of '/fr/node/123', which I reported here: https://www.drupal.org/node/2707879
In my opinion using aliased path is not an option for the contextual module here primarily because the aliased path can change. I verified that with patch 8 and trying to rename a node with an automatic alias which afterwards resulted in a 404. If the aliased path should be returned this would have to be done during the processing of the submission, the destination parameter has to be kept as an internal path.
Comment #15
droplet commented#10, #11, #12,
A bit helpful for SEO. Because SEO also including sharing links. (But really a little only.) Also UX problems.
#14,
Yes, that's a case
Comment #16
mondrakeRelated, #2687453: drupalSettings.path.currentPath refers to the route's URL even when page is accessed through an URL alias
Comment #18
reekris commentedI just wanted to chime in that I solved this problem for a current Drupal 8 project using the Redirect module. After activating "Normalize aliases" in the Redirect settings the module redirects me to the aliased url after editing a node. It will also solve the problem mentioned in #14 so that if the alias gets changed by the edits I make to the node, I will still be redirected to the new alias.
So maybe this should not be a responsibility of the core functionality but of third party modules, as mentioned in #2?
Comment #21
gngn commentedI do not like to use the (aliased) pathname from the browser, I think something like en/node/XYZ is much cleaner.
The solution proposed by jherencia at 2707879#10 worked for me, patch in #12
Comment #22
droplet commentedComment #25
peter törnstrand commentedFor 8.5.6...
Comment #26
peter törnstrand commentedComment #27
caspervoogt commentedThis is also an issue when configuring blocks from the frontend. If the block is assigned to /some-page and then you configure it from /some-page, after saving the block it redirects you to /node/123 (or whatever node ID /some-page has). And the block then does not show, unless it is assigned to both /some-page and /node/123. That's more than just annoying... it is bewildering to site editors..
Comment #29
eugene.britFor 8.6.12
Comment #34
t-loRe-roll for 9.1x+
Comment #35
malcomio commentedComment #36
mitthukumawat commentedI have tested patch #34 manually and it reflects the changes in contextual links aliases instead using internal path of any node.
I have created a taxonomy with url alias and before patch, it was appearing
taxonomy/1/editbut after patch, it is now showing url alias in destination of link.Adding after patch screenshot for reference.
Comment #38
larowlan#14 sounds like this doesn't work with language prefixes
#18 points out that there's a contrib way to solve this - are we sure we still want to pursue this?
We need this change in the .es6 version, with the .js version generated from running yarn build
Comment #41
phoang commentedPatch for 9.5.2
Comment #42
phoang commentedApplies patch for core 9.5.2
Comment #43
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
This is tagged for needing tests which still need to happen.
Comment #44
_utsavsharma commentedPatch for 10.1.x as in the previous test the patch failed to apply.
Comment #45
praveenpb commentedIt seems this has been fixed in 9.5.4+ and 10.0.4+ versions. Can we close this issue?
Comment #46
smustgrave commentedClosing as a duplicate of #2738547: Contextual Links do not respect parameters in the destination