Generated with the help of an LLM.

Problem/Motivation

When I click a component in the Canvas that is (or contains) a link to a same-page anchor (href="#foo"), the sidebar opens, but the Canvas also scrolls to #foo. The component I just selected is no longer in view.

The click handler in builder_frame.js blocks every link, but lets #… through. That exception comes from the Preview (#3620333): there it is useful, because the Preview is browsed. #3562060 then copied the exception into the Canvas "as in the live preview". Before that, the Canvas blocked every link. In the Canvas, a click means "select", so following the anchor doesn't help.

Steps to reproduce

  1. Add a component that renders as <a href="#some-id">, for example a card with a URL like #some-id, plus a target with that id lower on the page.
  2. Open the builder and click the card in the Canvas.
  3. The sidebar opens, and the Canvas jumps to #some-id.

Proposed resolution

In the Canvas click handler, call preventDefault() for every a[href] again, anchors included. Keep the exception in the Preview (preview_mode.js).

Remaining tasks

MR with a Playwright test.

Related: #3623984

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

hydra created an issue. See original summary.

pdureau’s picture

Bug reports go in display_builder-1.0.0-beta scope by default.

Is it ready for review?