Closed (fixed)
Project:
Experience Builder
Version:
0.x-dev
Component:
Page builder
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
25 Feb 2025 at 19:42 UTC
Updated:
31 Mar 2025 at 13:59 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
lauriiiAlso, the "Edit" button in the context menu isn't working for components in the layers or in the preview.
Comment #3
sarvjeetsingh commentedHi @lauriii,
I attempted to reproduce the issue, but the context menu seems to be working correctly for both code components and library components.
I've attached screenshots for reference. Could you please provide more details if the issue persists on your end or if there are specific steps where it fails?
Looking forward to your insights!
Comment #4
lauriiiFrom @balintbrews on Slack:
Comment #5
wim leersUpdating title for consistent terminology.
Tagging per https://www.drupal.org/project/experience_builder/issues/3455753#release....
Comment #6
balintbrewsAdjusting the title to express that this is not the case before the component is dragged to the canvas. It's also any interaction that's lost, not just the contextual menu. You also can't drag the component again and its preview doesn't appear.
Comment #7
omkar-pd commentedAlso, the preview is not working for existing components (eg- Heading, Hero) once dragged to Canvas.
Comment #8
nagwani commentedComment #10
hooroomooComment #11
hooroomooHm i'm not able to reproduce this issue
Comment #12
hooroomooNevermind! I am able to reproduce it. I was clicking to insert instead of dragging.
Comment #13
hooroomooI think what's happening is when an item is dragged out of the Components list, a clone from SortableJS replaces it in the list. But that clone doesn't have any of the React event handlers that the original item had. So for example the component preview no longer works onMouseEnter, for all the components, not just code components.
So that's why it works when you close and re-open the Components list, since in that state, only the originals are there due to re-rendering, no clones.
Will continue tomorrow.
Comment #14
hooroomooUpdating title because this affects any item under the Components list, not just exposed code components.
Comment #15
omkar-pd commented+1 #13
I tried debugging this a couple of days ago and came to the same conclusion. I attempted to reattach the event listeners, but it didn’t work. I also tried replacing the cloned element with the original one, but the item in the event is different from the original element—it is the rendered output of that component.
Comment #16
balintbrewsI had an idea I wanted to quickly try. I'm just reading #13 now, I think it's the accurate description of the problem.
Something like this fixes it — re-triggering the
useEffecthook that initializes SortableJS in itsonEndhandler:Comment #17
hooroomooThe above didn't work for me. I wasn't able to find a good solution.
1. Calling something like
evt.clone.replaceWith(evt.item)would require changes tousePreviewSortable.tswhere it changes the innerHTML to the rendered markup (updateData()) so it can render in the preview and want to avoid changes to that file if possible.2. Tried #16 and similar things as the above to try to trigger a re-render of but I couldn't get it to work.
3. Confusing React by passing in a Math.random() like
<ListItem key={Math.random()} .../>kinda works but is bad practice and also causes SortableJS errors 😛 lolComment #18
hooroomooPaired with @balintbrews and we got a working solution :)) Setting a unique key to the component list onDragEnd instead of an individual list item works.
Comment #20
hooroomooComment #21
hooroomooComment #24
jessebaker commentedMerged!
Comment #25
nagwani commented