Issue #3509đź’¬ AnsweredOpened June 1, 2021by theSC0RP1 reactions

How to programmatically change componentFirst?

Quick answerby artf❤ 1

You have to retrigger the selection after changing that option editor.trigger('component:toggled')

Read full answer below ↓

Question

Hey @artf, I was trying toggle between using ids and classes for styling so I need to change the componentFirst attribute programmatically. But when I try to change the config, the behaviour doesn't change. This isn't working even in the demo. Steps to reproduce:Add two text blocksGive them the same class name.In the browser console, change the componentFirst property using editor.getConfig().selectorManager.componentFirst = false Add some color to the text. It is only added to the selected block P.S. I also tried doing editor.refresh() after changing the config but that did not change anythi...

Answers (2)

artf• June 10, 2021

You have to retrigger the selection after changing that option editor.trigger('component:toggled')

GJSBlock• May 17, 2026

Thanks for reporting this, @theSC0RP. Great question about How to programmatically change componentFirst?. The recommended approach with Components is to use the event-driven API. Start here: Check the GrapesJS documentation for your specific module Look for the on() event listener method Most oper...

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 →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.