Problem/Motivation

Links in Canvas and Preview are blocked so the user cannot leave the builder by accident. The blocking only works on first page load:

  • Canvas: click handlers are bound to each link once, in disableInsideLinks(). Links added later, like a menu block added from Libraries or moved in the canvas, are not blocked until a page refresh.
  • Preview: when the behavior attaches, the iframe still reports its empty starting page (about:blank) as loaded. The blocker binds to that empty page, not to the real render that replaces it. Links stay clickable until the first edit refreshes the preview.
  • Contextual links: they are shown in both panels. They are admin chrome, not part of the display, and they lead out of the builder.

Steps to reproduce:

  1. Open a page layout builder, e.g. /admin/structure/page-layout/default/builder
  2. From Libraries, add Menus > Main navigation to the canvas
  3. Click a menu link: the browser leaves the builder

Proposed resolution

  • Canvas: use one click listener on the island in place of per-link listeners, so links added later are blocked too.
  • Preview: bind the blocker once the iframe's real document has loaded, not its empty starting document.
  • Hide contextual links ([data-contextual-id], .contextual) in Canvas with CSS, and inside the Preview iframe with a style rule added on load.
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

mogtofu33 created an issue. See original summary.

mogtofu33’s picture

Assigned: mogtofu33 » Unassigned
Status: Needs work » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • mogtofu33 committed 25604d08 on 1.0.x
    task: #3623984 Links are clickable in Canvas and Preview after adding or...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.