From 286d6e50827776a1170e5436ba51b5b8b1c691f1 Mon Sep 17 00:00:00 2001
From: David Tsay <3614296+davetsay@users.noreply.github.com>
Date: Tue, 5 Nov 2019 16:20:26 -0800
Subject: [PATCH] Issue 2472 Disable selection in layouts when previewing
(#2530)
* ISSUE-2472: disable selection in layouts during preview
---
src/selection/Selection.js | 17 +++++++++++++++++
src/ui/layout/Layout.vue | 4 +++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/src/selection/Selection.js b/src/selection/Selection.js
index 7e8354c6dd..f94adc388a 100644
--- a/src/selection/Selection.js
+++ b/src/selection/Selection.js
@@ -166,6 +166,17 @@ define(
return this.selected.some(selectionPath => _.isEqual(selectionPath[1], selectable[1]));
};
+ /**
+ * @private
+ */
+ Selection.prototype.isSelectable = function (element) {
+ if (!element) {
+ return false;
+ }
+
+ return !!element.closest('[data-selectable]');
+ };
+
/**
* @private
*/
@@ -211,8 +222,14 @@ define(
context: context,
element: element
};
+
+ if (!this.isSelectable(element)) {
+ return () => {};
+ }
+
var capture = this.capture.bind(this, selectable);
var selectCapture = this.selectCapture.bind(this, selectable);
+
element.addEventListener('click', capture, true);
element.addEventListener('click', selectCapture);
diff --git a/src/ui/layout/Layout.vue b/src/ui/layout/Layout.vue
index 8952bd191a..817480f704 100644
--- a/src/ui/layout/Layout.vue
+++ b/src/ui/layout/Layout.vue
@@ -39,7 +39,9 @@
+ :showEditView="true"
+ data-selectable
+ >