RemoveChildren in Components.js being executed with an undefined component
Question
Hi @artf long time, I hope everything is going good with you and your closed ones.
There's a small case that I wanted to ask what you think before i make a request.
I have a custom link component that is wrapped around a li tag, this link has an event to remove its parent li when is removed.
If i delete the link directly everything works fine, but if I remove an outer parent that contains both li and link components, removeChildren in Components.js gets executed with an undefined component, causing this error to happen
Uncaught TypeError: can't access property "getId", removed is undefined
removeChildren Components.js:30
This is due to the object being deleted during another callback (the custom one i made) before the removeChildren gets the parameter.
This can be solved by just returning if the removed param is falsey but maybe it's too hackish and i should look for another solution and not make the component delete its parent.
removeChildren(removed, coll, opts = {}) {
if (!removed) {
return;
}
What do you think?
Thanks!
Answers (1)
Thanks Juan, all good and I hope the same to you :)
This can be solved by just returning if the removed param is falsey but maybe it's too hackish and i should look for another solution and not make the component delete its parent.
Well, technically removeChildren shouldn't be called "without" removed, so if that condition solves your issue I think it's good.
I also think that your case might be used by someone else
Related Questions and Answers
Continue research with similar issue discussions.
Issue #951
[QUESTION] Selection of custom components not possible from canvas.
Hey, I tried to figure this out by myself, but I'm feeling I'm going a little bit in circles. So I hope you will have some time to read thi...
Issue #5334
BUG: Selection of custom component type not working in the canvas
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome, Opera, Edge, etc Reproducible demo...
Issue #2647
Drag placeholder does not calculate the correct width.
HI @artf, I hope you are having a nice day. There's a small issue with the drag placeholder when a block is being dragged into a possible c...
Issue #2522
Warning on setting up wrapper's height to 100%
Hi @artf I hope everything's going well. This is more like a reminder or a warning message for an issue I've just had that it took me some...
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.