Wrong event triggered by ApiController::attachToSlot()

Created on 11 August 2025, 2 days ago

Problem/Motivation

ON_ATTACH_TO_ROOT is unexpected here:

public function attachToSlot(Request $request, string $builder_id, string $instance_id, string $slot): HtmlResponse {
...
  return $this->dispatchDisplayBuilderEvent(
    $is_move ? DisplayBuilderEvents::ON_MOVE : DisplayBuilderEvents::ON_ATTACH_TO_ROOT,
    $builder_id,
    NULL,
    $instance_id,
    $parent_id,
  );

Same onAttachToRoot & onAttachToSlot:

  • Buttons: HistoryButtons, StateButtons, ActiveUsers
  • Contextual: UiStylesPanel, UiSkinsPanel, InfoPanel, InstanceFormPanel, VisibilityConditionsPanel
  • View: LogsPanel, PreviewPanel

Different onAttachToRoot & onAttachToSlot:

  • BuilderPanel and its children: LayersPanel, TreePanel

This must affect performance (we are sending way too much HTML than necessary) and this may explain some weird behaviours there.

Proposed resolution

Fix ApiController::attachToSlot() and test BuilderPanel LayersPanel & TreePanel. Maybe some JS or PHP mechanism were built around this error.

🐛 Bug report
Status

Active

Version

1.0

Component

UI/UX/Islands

Created by

🇫🇷France pdureau Paris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @pdureau
  • 🇫🇷France Grimreaper France 🇫🇷
  • 🇫🇷France pdureau Paris

    Accordign to Jean:

    It's here because if you move to root a component there is no slot, it must be added to the root, if not it will fail.

    So the expected change must be to keep the mechanism but to rename something and add a comment

  • 🇫🇷France Grimreaper France 🇫🇷
  • 🇫🇷France Grimreaper France 🇫🇷

    In attachToSlot, what is the point to have $instance_id in the route, when it is also obtained with parameters? $request->request->has('instance_id')

    Except for a debug message.

    Also if we "move to root a component", why is it the attachToSlot method that is called?

    Not sure I am the best to know what is to be renamed/commented.

  • 🇫🇷France pdureau Paris

    Not sure I am the best to know what is to be renamed/commented.

    @mogtofu33?

  • 🇫🇷France mogtofu33

    Both instances are different, moving something to a slot trigger a post:

    • The path instance_id is the component instance_id that receive the request at the end of drag and triggered the post
    • The request instance_id is the component / block moved in the slot

    Also if we "move to root a component", why is it the attachToSlot method that is called?

    There's a chance it's not needed, this where we need to investigate. This is mostly a legacy code.
    There is 2 cases:

    • Move from outside (library, an other dropzone like layers -> builder) to root
    • Or existing instance moved from a slot to root
Production build 0.71.5 2024