fix(label-editing): prevent direct editing after create

Closes #1164
This commit is contained in:
Niklas Kiefer 2019-08-12 15:48:48 +02:00 committed by merge-me[bot]
parent bf180321a3
commit 715d2cca2e
2 changed files with 74 additions and 8 deletions

View File

@ -70,7 +70,8 @@ export default function LabelEditingProvider(
eventBus.on('create.end', 500, function(event) {
var element = event.shape,
var context = event.context,
element = context.shape,
canExecute = event.context.canExecute,
isTouch = event.isTouch;
@ -90,6 +91,10 @@ export default function LabelEditingProvider(
return;
}
if (context.hints && context.hints.createElementsBehavior === false) {
return;
}
activateDirectEdit(element);
});

View File

@ -13,6 +13,10 @@ import {
getLabel
} from 'lib/features/label-editing/LabelUtil';
import {
createCanvasEvent as canvasEvent
} from '../../../util/MockEvents';
var MEDIUM_LINE_HEIGHT = 12 * 1.2;
var DELTA = 3;
@ -164,17 +168,23 @@ describe('features - label-editing', function() {
]
}));
var elementRegistry,
eventBus,
directEditing;
var create,
directEditing,
dragging,
elementFactory,
elementRegistry,
eventBus;
beforeEach(inject([
'elementRegistry', 'eventBus', 'directEditing',
function(_elementRegistry, _eventBus, _directEditing) {
'create', 'directEditing', 'dragging',
'elementFactory', 'elementRegistry', 'eventBus',
function(_create, _directEditing, _dragging, _elementFactory, _elementRegistry, _eventBus) {
create = _create;
directEditing = _directEditing;
dragging = _dragging;
elementFactory = _elementFactory;
elementRegistry = _elementRegistry;
eventBus = _eventBus;
directEditing = _directEditing;
}
]));
@ -418,6 +428,56 @@ describe('features - label-editing', function() {
});
describe('after elements create', function() {
var createTaskElement;
beforeEach(function() {
createTaskElement = function(context) {
var shape = elementFactory.create('shape', { type: 'bpmn:Task' }),
parent = elementRegistry.get('SubProcess_1'),
parentGfx = elementRegistry.getGraphics(parent);
create.start(canvasEvent({ x: 0, y: 0 }), [ shape ], context);
dragging.hover({
element: parent,
gfx: parentGfx
});
dragging.move(canvasEvent({ x: 400, y: 250 }));
dragging.end();
};
});
it('should activate', function() {
// when
createTaskElement();
// then
expect(directEditing.isActive()).to.be.true;
});
it('should NOT activate with behavior hint', function() {
// when
createTaskElement({
hints: { createElementsBehavior: false }
});
// then
expect(directEditing.isActive()).to.be.false;
});
});
});
@ -453,6 +513,7 @@ describe('features - label-editing', function() {
});
describe('sizes', function() {
beforeEach(bootstrapModeler(diagramXML, {