[QUESTION] custom component type not found and traits not working after page load
Question
Hi @artf
I have created a very basic custom component named 'custom_section' which uses traits to change the component's background-color by adding a class. Pretty straightforward.
I have created two blocks:
- Section - includes only the component.
- Section collection - includes a collection of DOM elements and the component.
Unfortunately, I'm having 2 issues as detailed below.
Issue 1:
- A block with custom component is dropped in canvas - visually appears fine.
- When changes are saved via local storage and page is reloaded - the following console warning appears: "Component type 'custom_section' not found".
What am I doing wrong here? Is the isComponent logic wrong?
Issue 2 - same as issue #2106
- A block with custom component is dropped - visually appears fine and can select traits and modify component's background-color.
- When changes are saved via local storage and page is reloaded - the custom defined traits are no longer present and the default attributes are displayed.
This started occurring after latest update (v0.14.62). In the latest changes, it mentions "Remove traits information from component JSON". Is this what's causing the issue and if so, is there a workaround? https://github.com/artf/grapesjs/releases/tag/v0.14.62
I've created a reduced use case demo here: https://codepen.io/selcukcura/pen/ewyRqB?editors=1010
I would really appreciate some help with this as I've been stuck on it for a while.
Thanks, Selcuk
Answers (3)
Try to put your custom component definitions in a plugin and see if it works
@selcukcura are it is working when putting it in plugin ?
Much appreciated @artf, placing my custom component in a plugin solved both issues!
Out of curiousity, are there any particular reasons why it now works as a plugin and not otherwise ?
@alialrabi Yes, I managed to get it working. Try using the plugin boilerplate if you haven't already.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2226
[QUESTION] Updating a component type trait definition after init
I have created a custom component & block which is used to display/embed uploaded files. I have defined traits for this component see below...
Issue #2952
Custom component is not working after saving.
Hi, I have Button-Link custom component created, and when I dragged into canvas for the first time component is detecting its attributes an...
Issue #3213
QUESTION: How to save the dynamically added traits
Hi, @artf, I have a custom component that has a button trait. When the button is pressed, I am adding a custom trait dynamically using comp...
Issue #1683
How to change id/class when new element drop on editor or render element with dynamic ip?
Hello @artf , Hope you are doing well. I have two questions regards dynamic blocks adding, 1) Is it possible to render the block with dynam...
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.