[BUG] Custom Component Class is not being rendered unless trait changes
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)
Hi @adamwpe please use classes attribute instead of attributes:
//...
resizable: true,
editable: true,
hoverable: true,
classes:['btn','gjs-button'],
//...
Cheers!
Oh Thanks, @pouyamiralayi,
Seen someone used attributes and assume that was the correct method - worked like a charm!
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 then change the trait, it will then default back to its original settings (AKA losing the width).
Related Questions and Answers
Continue research with similar issue discussions.
Issue #987
[BUG/Question] Dropdown indicator not displayed for a custom trait
Hello, the dropdown (select) element arrow indicator icon is not rendered when adding a custom trait to a component: I'm using following co...
Issue #1843
Class on different states are not being applied to those states.
I'm trying to apply a class on hover of a component and the class is being applied but not on hover, it applies with normal state. Please l...
Issue #3224
BUG: changesCount is not incremented, when changes are applied in any Text component
https://user-images.githubusercontent.com/64096863/104047608-af352b00-51c0-11eb-8261-1d7ae9277d25.mp4 The parameter "changesCount" is not i...
Issue #5379
BUG: Class modifications of components are not automatically detected
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? Chrome Version 116Reproducible demo link htt...
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.