Issue #2136Opened July 12, 2019by selcukcura2 reactions

[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:

  1. Section - includes only the component.
  2. Section collection - includes a collection of DOM elements and the component.

Unfortunately, I'm having 2 issues as detailed below.

Issue 1:

  1. A block with custom component is dropped in canvas - visually appears fine.
  2. 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

  1. A block with custom component is dropped - visually appears fine and can select traits and modify component's background-color.
  2. 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)

artfJuly 15, 20192 reactions

Try to put your custom component definitions in a plugin and see if it works

alialrabiJuly 16, 20190 reactions

@selcukcura are it is working when putting it in plugin ?

selcukcuraJuly 16, 20190 reactions

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.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.