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.

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

pdureau created an issue. See original summary.

pdureau credited mogtofu33.

pdureau’s picture

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

grimreaper’s picture

Assigned: Unassigned » grimreaper
grimreaper’s picture

Assigned: grimreaper » Unassigned

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.

pdureau’s picture

Assigned: Unassigned » mogtofu33

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

@mogtofu33?

mogtofu33’s picture

Assigned: mogtofu33 » Unassigned

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
pdureau’s picture

pdureau’s picture

Assigned: Unassigned » mogtofu33
Status: Active » Needs review
Issue tags: -display_builder-1.0.0-beta +display_builder-1.0.0-beta4

Hi,

#3576984: Error: [attachToSlot] moveToSlot failed with invalid data has fixed:

-      $is_move ? DisplayBuilderEvents::ON_MOVE : DisplayBuilderEvents::ON_ATTACH_TO_ROOT,
+      $is_move ? DisplayBuilderEvents::ON_MOVE : DisplayBuilderEvents::ON_ATTACH_TO_SLOT,

Does that mean this issue can be closed as "duplicate" or "outdated"?

mogtofu33’s picture

Assigned: mogtofu33 » Unassigned
Status: Needs review » Fixed

Seems yes.

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.

Status: Fixed » Closed (fixed)

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