Issue #2727✓ SolvedOpened April 22, 2020by adamwpe6 reactions

Custom Component Class is not being rendered unless trait changes

Quick answerby pouyamiralayi4

Hi @adamwpe please use `classes attribute instead of attributes`: Cheers!

Read full answer below ↓

Question

I think this is a bug, Basically, I have a custom component that has an attribute of a class ('gjs-button'), but that class only appears to get rendered/applied when a trait is changed.Drag and drop the component: Amend the component Trait.The component is rendered again, but now you can see the class 'gjs-button' has been applied. I've created an example: https://jsfiddle.net/tb2gyas8/3/ Is that a bug? Or is there something wrong messing up the component? Thanks Adam

Answers (3)

👍 Most helpfulpouyamiralayiApril 23, 2020

Hi @adamwpe please use classes attribute instead of attributes:

//...
resizable: true,
editable: true,
hoverable: true,   
classes:['btn','gjs-button'],
//...

Cheers!

adamwpeApril 24, 2020

Oh Thanks, @pouyamiralayi,

Seen someone used attributes and assume that was the correct method - worked like a charm!

adamwpeApril 22, 2020

Appears a similar thing happens on save and reload. With this custom component, you are allowed to amend the size, but when you save and reload, the renderer doesn't draw it to the correct size, even though it has saved the correct width: Before Save: On Reload (It has the correct width): ] If I th...

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...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

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.