Issue #2368💬 AnsweredOpened November 2, 2019by trafalmejo0 reactions

All instances of custom component are being updated

快速解答by pouyamiralayi

Hi! i guess this is because your blocks posses similar classes and have selectors in common. in the latest version, `avoidInlineStyle` is true by default, so are you experiencing this on the latest version?

Read full answer below ↓

Question

Hi,

I created a custom component for a toggle button. My problem is that once I drag and drop more than one, and then I edit any of them, all instances are being updated in terms of color, size, etc. I am using the latest version of grapesjs

editor.BlockManager.add('toggle', {
  label: 'Toggle',
  attributes: { class:'fa fa-toggle-on'},
  category: 'Basic',
  content: '<label class="switch"> <input type="checkbox"><span class="slider"></span></label>'
})

All the animations and properties are in the CSS that I loaded in the editor. Any idea why this can be happening?

Answers (2)

pouyamiralayiNovember 2, 2019

Hi! i guess this is because your blocks posses similar classes and have selectors in common. in the latest version, avoidInlineStyle is true by default, so are you experiencing this on the latest version?

artfNovember 2, 2019

The guess by @pouyamiralayi is right, this happens because of the same classes and you have to toggle them in the style manager to make stylable only the component style. BTW I'll try, soon I hope, to provide a more intuitive solution

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.