How to programmatically change componentFirst?
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)
You have to retrigger the selection after changing that option editor.trigger('component:toggled')
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.
Issue #4196
Ids gets changed while trying to set components on the canvas using json
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome Reproducible demo link no link Desc...
Issue #5990
When you delete a component, duplicate classes between components will be deleted.
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome 126.0.6478.127(Windows) Reproducibl...
Issue #4310
Style Manager is inaccurate when using combined CSS selectors which contains "bout" and componentFirst = true
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome 100 Reproducible demo link https://...
Issue #3832
The css classes are removed and the autogenerated ids for each html tags gets changed ( Example : ivj5m-2) after each reload
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome Reproducible demo link Not there De...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →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.
Tutorial
Big Updates: TinyMCE 8 and Placeholder 2.0 for GrapesJS
In May we shipped major updates to two of our most popular GrapesJS plugins — TinyMCE Inline Text Editor and Placeholder.
Tutorial
Find the Right GrapesJS Plugin in Seconds: Smarter Discovery Is Live
We're shipping a set of discovery upgrades. New label filters, a proper compatibility switch for GrapesJS vs Studio, one-click and a smarter sort bar.
Tutorial
GrapesJS vs Webflow vs Tilda (2026): Honest Comparison, Pricing & Which to Pick
GrapesJS vs Webflow vs Tilda compared head-to-head: real 2026 pricing, SEO features, code export, and which one actually fits your project
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.