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:
- Open a page layout builder, e.g.
/admin/structure/page-layout/default/builder - From Libraries, add Menus > Main navigation to the canvas
- 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.
Issue fork display_builder-3623984
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
Comment #3
mogtofu33 commented