Issue #1536💬 AnsweredOpened October 23, 2018by dlorenzo0 reactions

Propagate different value

快速解答by artf

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: 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 propaga...

Read full answer below ↓

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)

artfOctober 30, 2018

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

imanubhardwajMay 24, 2019

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.

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 →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.