Skip to content

Commit

Permalink
Avoid dragging in canvas non-draggable components. Fixes #3014
Browse files Browse the repository at this point in the history
  • Loading branch information
artf committed Sep 14, 2020
1 parent 9c151bd commit a757310
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/dom_components/view/ComponentView.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,18 @@ export default Backbone.View.extend({
this.initComponents({ avoidRender: 1 });
this.events = {
...this.events,
...(draggableComponents && { dragstart: 'handleDragStart' })
...(this.__isDraggable() && { dragstart: 'handleDragStart' })
};
this.delegateEvents();
!modelOpt.temporary && this.init(this._clbObj());
},

__isDraggable() {
const { model, config } = this;
const { _innertext, draggable } = model.attributes;
return config.draggableComponents && draggable && !_innertext;
},

_clbObj() {
const { em, model, el } = this;
return {
Expand Down Expand Up @@ -290,12 +296,11 @@ export default Backbone.View.extend({
updateAttributes() {
const attrs = [];
const { model, $el, el, config } = this;
const { highlightable, textable, type, _innertext } = model.attributes;
const { draggableComponents } = config;
const { highlightable, textable, type } = model.attributes;

const defaultAttr = {
'data-gjs-type': type || 'default',
...(draggableComponents && !_innertext ? { draggable: true } : {}),
...(this.__isDraggable() ? { draggable: true } : {}),
...(highlightable ? { 'data-highlightable': 1 } : {}),
...(textable
? {
Expand Down

0 comments on commit a757310

Please sign in to comment.