Component Drag Event
Question
I want to know how can I get that component from which element is dragged and drop to the other component. I need to add a class if component become empty if element is dragged and droped to the outside element. I can get the component which dragged and in which it droped but not from where it dragged. Any Help would be appreciated.

Answers (3)
In your case, I think it would be better listen to inner components changes (eg. what if I delete all children components?), but currently, there is no such an event, so I'll try to add it for the next release. It should be something like this
editor.on('component:update:components', component => {
// just modify the view element
const el = component.getEl();
const hasChildren = component.components().length;
el.classList[hasChildren ? 'remove' : 'add']('component--is-empty');
})
@YashPrince how did you get the id of the dragged component and where it was dropped
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1951
[QUESTIONS] change or add event on add component from block
is it possible ?, change the drag and drop event to on click when adding a new component, I want to add components by clicking the block th...
Issue #673
how to render block manager outside container?
I'm new to this great library and it seems very neat and clean BUT here is the problem that I have. I'm having gjs rendered in the middle,...
Issue #563
Table <thead> and <tbody> tag gets Omitted
Hello, There is new issue with GrapesJS (maybe). I've created new component using bm.add() in which I've used a table element with <thead>...
Issue #1111
How to add parent class when drag element
Hi @artf, Hope you are doing fine. Please let us know how we can add the parent class of div when new element is dragged inside that div li...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.