[Question] Propagate different value
Question
Hi:
I'm trying to prevent children elements from being selected so only the top parent can be selected (so as to prevent removing children and only being able to work with whole blocks). I created a component that defines the parent with a selectable false and propagate: ['selectable']. This works ok but, of course, the parent can't be selected.
Any way I can add selectable: true to the parent and propagate a false value?
And, in a similar vein, is it possible to override propagation down the line? In the same experiment, I tried setting 'selectable: true' in a child component with no effect.
Thanks!
Answers (2)
Any way I can add selectable: true to the parent and propagate a false value?
I'd say that the only way is to create a wrapper in the middle:
<parent> <-- selectable
<div data-gjs-selectable="false" propagate..> <-- not selectable
<child>
...
And, in a similar vein, is it possible to override propagation down the line?
No, you can't stop the propagation only via props
If you need, you all the stuff, about the propagation, happens here: https://github.com/artf/grapesjs/blob/dev/src/dom_components/model/Component.js#L125-L135
I'm also facing this issue, where I have created a custom components with image wrapped inside a <a> tag, when I click on the component, image tag click is triggered rather than <a> tag click. Is there any solution to this?
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2861
[HELP] Get css of selected component and its children
Hi, i'm trying to implement possibility to save elements as custom blocks. How can i get css of component and its children? I can recursive...
Issue #1995
[QUESTION] Binded events are not being loaded (Just work properly on mozilla firefox)
So I am using local Storage. I added some events to the component this way. Every time I add the component it works just fine. However, If...
Issue #1750
[Question] Show drawing outlines only under actively editing blocks
Is it possible to show show drawing outlines only for the currently selected (with all children) and for the hovered elements? Thus all oth...
Issue #3258
QUESTION: Prevent/Disable Custom Blocks from being dropped inside other Custom Blocks
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 Secti...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.