Issue #2487Opened January 2, 2020by msantore5 reactions

[BUG] Updating a trait resets the component styles

Question

I'm having an issue with Traits, wondering if this may be a bug. When I update the fontColor or fontSize trait, the other traits reset.

Video: https://www.loom.com/share/6a40830699ad4c4590363f2641a07eac

Code: https://github.com/msantore/vue-builder/blob/master/src/plugins/materials/components/index.js#L362

GrapesJS Version: 0.15.9

Answers (3)

pouyamiralayiJanuary 3, 20203 reactions

@msantore you are using setStyle which will override the previous styles. use it like below:

link[0].setStyle({ ...link[0].getStyle(), color: `${value}` });

cheers!

msantoreJanuary 3, 20201 reactions

That fixed it, thanks!

artfJanuary 4, 20201 reactions

You can also use addStyle({ color: ${value} }) which does the same thing

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.