Can't select the model using editor.select()
@artf , @pouyamiralayi :I need this condition inside the 'canvas:drop' event editor.on('canvas:drop', ()=>{ ... ... // My code to select the first component is here //... ... })
Read full answer below βQuestion
I am trying to select the first component in the editor by using editor.select(editor.DomComponents.getComponents().models[0]). It is not working.
Answers (3)
@artf , @pouyamiralayi :I need this condition inside the 'canvas:drop' event editor.on('canvas:drop', ()=>{ ... ... // My code to select the first component is here //... ... })
@naveen-15697 you can achieve this with:
editor.on('block:drag:stop', (m) => {
if(m){
editor.select(editor.getComponents().models[0])
}
})
cheers!
@pouyamiralayi Thanks! It's working now.
@artf , But, Why it is not working in 'canvas:drop' event?
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2549
Update component view on property change
Hi everyone, I'm trying to create a component that will update it's view based on a property value My approach is bassed on #1227 and on th...
Issue #3014
Move component from Child
Hi, i'm trying to make custom components composed with other components. No problem to do that. I'm facing an issue when i want to move the...
Issue #1998
Extending Link component not working properly.
hello @hello @artf I am trying to extend the link component and add new traits like href and target the code is given below. `function load...
Issue #1091
How to select the first Component
I want to launch the editor with the style manager visible and populated. Meaning that a component is selected by default and the style man...
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
Messaging on gjs.market: talk to a studio before you buy, not after
We've launched private messaging between buyers and studios. One thread per buyerβstudio pair, the whole history in one place.
Tutorial
Vanilla GrapesJS vs GrapesJS With Plugins: What You Actually Get Out of the Box (2026)
New to GrapesJS? See exactly what the stock editor gives you, where it falls short, and which plugins close the gaps β a beginner-friendly 2026 comparison
Tutorial
Introducing GJS.Market Services: ship your GrapesJS editor without the integration risk
It's everything that usually eats weeks of engineering time, scoped and priced up front. No open-ended hourly surprises.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.