Issue #2487✓ SolvedOpened January 2, 2020by msantore5 reactions

Updating a trait resets the component styles

快速解答by pouyamiralayi3

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

Read full answer below ↓

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)

👍 Most helpfulpouyamiralayiJanuary 3, 2020

@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, 2020

That fixed it, thanks!

artfJanuary 4, 2020

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

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.