Problem/Motivation

After #3308432: The link on the Image tag is redirecting to an undefined page from the node preview screen, when previewing an edited node if you enabled the "Leave preview?" diaolog, press "Back to content editing" button to open a dialog, this dialog has a "Leave Preview" button that points to undefined.

Leave preview dialog

Steps to reproduce

  1. Edit/Create a node
  2. Click on "Preview" button
  3. Once on the preview, click on "Back to content editing" button
  4. With the dialog opened, click on "Leave preview" button

Proposed resolution

On the file node.preview.js, look for the original "Back to content editing" button using the id "edit-backlink", extract the href and set this to the windows.top.location.href

Issue fork drupal-3541343

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jesus_md created an issue. See original summary.

jesus_md’s picture

I have created a path with the proposed solution I mentioned, on our projects solve this error.

jesus_md’s picture

Issue tags: -JavaScript +JavaScript
jesus_md’s picture

jesus_md’s picture

jesus_md’s picture

Issue summary: View changes
jesus_md’s picture

Status: Needs review » Closed (duplicate)
jesus_md’s picture

norman.lol’s picture

Version: 10.4.x-dev » 10.6.x-dev
Assigned: jesus_md » Unassigned
Status: Closed (duplicate) » Active
Issue tags: -JavaScript, -frontend, -Drupal 10
Related issues: +#3308432: The link on the Image tag is redirecting to an undefined page from the node preview screen

This here is a follow up of that other issue.

norman.lol’s picture

Title: Leave preview points to undefined instead of node's edit page » "Leave preview" points to undefined instead of node's edit page
Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new504 bytes

Re-uploading the patch from #3308432-42: The link on the Image tag is redirecting to an undefined page from the node preview screen that fixes this issue. Credit needs to be given to @keshavv.

norman.lol’s picture

Hmmm, okay, just noticed now that #10 is just reverting what was done in #3308432: The link on the Image tag is redirecting to an undefined page from the node preview screen, so I guess this can't be the fix. Looks like we have to check both. Like this maybe:

let href = event.currentTarget.href;
if (href === undefined) {
  href = event.target.href;
}
window.top.location.href = href;
norman.lol’s picture

StatusFileSize
new719 bytes
new613 bytes
smustgrave’s picture

Version: 10.6.x-dev » 11.x-dev
Status: Needs review » Needs work

Fixes need to land in 11.x first as the development branch. Also fixes should be in MRs vs patches.

As a bug will also need test coverage too.

Thanks!

norman.lol’s picture

MRs is nice yeah, got created already. But as long as GitLab doesn't offer a way to get static, non-changing patches, we still need that patch here.

norman.lol’s picture

Issue tags: +Needs tests
smustgrave’s picture

FYI you had it right the first time. MR has to go to 11.x first. Then depending when it lands committer decides to backport to relevant branches.

norman.lol’s picture

Would have needed a rebase first.

rmpereira’s picture

I had the issue on Drupal 11.2.4.
After applying the patch, I confirm that the problem is fixed.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

julio_retkwa’s picture

StatusFileSize
new673 bytes

Adding patch to Drupal 11.3.3

scott_euser made their first commit to this issue’s fork.

scott_euser’s picture

I started to attempt to add test coverage for this, but I think issue summary steps to reproduce are inaccurate. At least for me with Gin & Navigation, if I click 'Content' (or any Navigation link) since they are outside the preview area, the JS the triggers the Leave Preview process. Reproducing that in the tests, its successful even without the JS change, whereas in my site, the JS change is needed.

So functionality-wise RTBC +1 from me BUT still needs work as this test coverage passes even without the change as is.

scott_euser’s picture

Hopefully at least the test coverage gets someone going once issue summary is updated with clearer steps.

dennis_meuwissen’s picture

StatusFileSize
new889 bytes

We ran into this issue as well, in our case the detected href was not correct because the event target was an img tag inside an a tag:

<a href="/">
    <img src="/themes/custom/something/assets/logo.svg">
</a>

event.target and event.currentTarget always pointed to the img tag. What we ended up doing was getting the href from this before the dialog is built.