RemoveChildren in Components.js being executed with an undefined component
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 condi...
Read full answer below β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 #5334
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 #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 #6102
Traits Not Displayed After Reloading Editor for Custom Component
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? Chrome 91VReproducible demo link https://jsf...
Issue #6081
Custom Component not able to visible in grapsJs/studio at first rendering
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? chromeReproducible demo link https://stackbl...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins βPremium plugins ship with support, regular updates, and production-ready features β save days of integration work.
Browse premium plugins βBrowse Plugin Categories
Jump directly to plugin category pages on the marketplace.