From 66c7a31d340184dbfce03efd2a4b45f94d1ee56c Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Mon, 15 Sep 2014 14:42:43 +0200 Subject: [PATCH] chore(label-editing): deselect element during editing --- .../label-editing/LabelEditingProvider.js | 36 +++++++++++++++---- lib/features/modeling/LabelSupport.js | 2 +- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/lib/features/label-editing/LabelEditingProvider.js b/lib/features/label-editing/LabelEditingProvider.js index 7662707c..588c3a05 100644 --- a/lib/features/label-editing/LabelEditingProvider.js +++ b/lib/features/label-editing/LabelEditingProvider.js @@ -16,7 +16,7 @@ var MIN_BOUNDS = { }; -function LabelEditingProvider(eventBus, canvas, directEditing, commandStack) { +function LabelEditingProvider(eventBus, canvas, directEditing, commandStack, injector) { directEditing.registerProvider(this); commandStack.registerHandler('element.updateLabel', UpdateLabelHandler); @@ -40,10 +40,37 @@ function LabelEditingProvider(eventBus, canvas, directEditing, commandStack) { directEditing.complete(); }); + // remove and restore selection during direct editing + + (function() { + + try { + var selection = injector.get('selection'); + + var localSelection; + + eventBus.on('directEditing.activate', function() { + localSelection = selection.get(); + selection.select(null); + }); + + eventBus.on('directEditing.deactivate', function() { + selection.select(localSelection); + localSelection = null; + }); + } catch (e) { } + + })(); + + this._canvas = canvas; this._commandStack = commandStack; } +LabelEditingProvider.$inject = [ 'eventBus', 'canvas', 'directEditing', 'commandStack', 'injector' ]; + +module.exports = LabelEditingProvider; + LabelEditingProvider.prototype.activate = function(element) { @@ -112,9 +139,4 @@ LabelEditingProvider.prototype.update = function(element, newLabel) { element: element, newLabel: newLabel }); -}; - - -LabelEditingProvider.$inject = [ 'eventBus', 'canvas', 'directEditing', 'commandStack' ]; - -module.exports = LabelEditingProvider; \ No newline at end of file +}; \ No newline at end of file diff --git a/lib/features/modeling/LabelSupport.js b/lib/features/modeling/LabelSupport.js index 3d4117f8..28e6b55d 100644 --- a/lib/features/modeling/LabelSupport.js +++ b/lib/features/modeling/LabelSupport.js @@ -42,7 +42,7 @@ function LabelSupport(eventBus, modeling, bpmnFactory) { var label = element.label; - if (label && dragContext.shapes.indexOf(label) === -1) { + if (label && !label.hidden && dragContext.shapes.indexOf(label) === -1) { dragContext.shapes.push(label); } });