Prevent/Disable Custom Blocks from being dropped inside other Custom Blocks
You can use :not() selector, eg. :not(.except-this-class)
Read full answer below โQuestion
Hello, I have a custom component, let's call it a Section Block. I want to prevent the user from dropping Section Blocks inside other Section Blocks. Is that possible? Ref: https://grapesjs.com/docs/modules/Components.html#define-custom-component-type I am aware of the draggable/droppable options that I can define on new component types. My understanding of these options is that they are inclusive. Is there a way to make draggable exclusive, where I say, "this block can be dropped anywhere EXCEPT [[component type]]"?
Answers (4)
You can use :not() selector, eg. :not(.except-this-class)
Thanks @artf . This solution works, mostly. Now I am encountering a new problem where some placeholder text is disappearing. On some elements inside my blocks, I'll have an HTML element with a text node, then some other nested html element. An example would be a link tag containing an icon. When I...
You're defining the component with the old API, which requires other stuff to work properly and that might be the cause of the issue (I've tried on my side and everything works as expected). Please check here for the correct API https://grapesjs.com/docs/modules/Components.html#define-custom-compon...
Thanks for reporting this, @stljeff1. Great question about Prevent/Disable Custom Blocks from being dropped inside other Custom Blocks. 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() ev...
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3688
How to customize a component
I read this document https://grapesjs.com/docs/modules/Components.html#define-custom-component-type and tried to write the following code....
Issue #3574
Adding traits are not picked up by trait manager.
Following example from docs . Is there further configurtion to make new traitsa show for elements? The example using the input does not run...
Issue #5768
Wrong Type for "content" property in BlockProperties
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v122 Reproducible demo link not app...
Issue #4384
Index.d.ts says that components must be Backbone.Collection<Component> but the docs say Component[] is also accepted
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? AnyReproducible demo link https://grapesjs.c...
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
Introducing Search on GJS.Market
GJS.Market now has one search across everything we publish โ plugins, articles, community questions, guides, authors and services. Press โK from any page.
Tutorial
GJS.Market Is Now Available for India ๐ฎ๐ณ
GJS.Market is expanding its global presence with a dedicated experience for developers, agencies, SaaS companies, and digital creators in India
Tutorial
How to Build an AI-Powered Page Builder with GrapesJS in 2026
What we learned building GJSDocs โ from simple AI text generation to structured, context-aware visual editing
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.