grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

[BUG] Custom Component Class is not being rendered unless trait changes

Open adamwpe opened this issue 6 years ago • 3 comments

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.

  1. Drag and drop the component: Capture1

  2. Amend the component Trait. Capture3

  3. The component is rendered again, but now you can see the class 'gjs-button' has been applied. Capture4

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

adamwpe avatar Apr 21 '20 21:04 adamwpe

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

On Reload (It has the correct width): Captureb]

If I then change the trait, it will then default back to its original settings (AKA losing the width).

adamwpe avatar Apr 22 '20 19:04 adamwpe

Hi @adamwpe please use classes attribute instead of attributes:

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

Cheers!

pouyamiralayi avatar Apr 23 '20 20:04 pouyamiralayi

Oh Thanks, @pouyamiralayi,

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

adamwpe avatar Apr 23 '20 22:04 adamwpe