fix(label-editing): complete on autoPlace start

Closes #764
This commit is contained in:
Nico Rehwaldt 2018-02-15 23:04:02 +01:00 committed by Nico Rehwaldt
parent 25dc30df06
commit b35aa48d14
2 changed files with 33 additions and 7 deletions

View File

@ -32,7 +32,8 @@ function LabelEditingProvider(
eventBus.on([ eventBus.on([
'element.mousedown', 'element.mousedown',
'drag.init', 'drag.init',
'canvas.viewbox.changing' 'canvas.viewbox.changing',
'autoPlace'
], function(event) { ], function(event) {
directEditing.complete(); directEditing.complete();
}); });

View File

@ -1,12 +1,13 @@
'use strict'; 'use strict';
/* global bootstrapViewer, inject */ /* global bootstrapModeler, inject */
var labelEditingModule = require('lib/features/label-editing'), var labelEditingModule = require('lib/features/label-editing'),
coreModule = require('lib/core'), coreModule = require('lib/core'),
draggingModule = require('diagram-js/lib/features/dragging'), draggingModule = require('diagram-js/lib/features/dragging'),
modelingModule = require('lib/features/modeling'); modelingModule = require('lib/features/modeling'),
autoPlaceModule = require('lib/features/auto-place');
var LabelUtil = require('lib/features/label-editing/LabelUtil'); var LabelUtil = require('lib/features/label-editing/LabelUtil');
@ -40,12 +41,13 @@ describe('features - label-editing', function() {
describe('basics', function() { describe('basics', function() {
beforeEach(bootstrapViewer(diagramXML, { beforeEach(bootstrapModeler(diagramXML, {
modules: [ modules: [
labelEditingModule, labelEditingModule,
coreModule, coreModule,
draggingModule, draggingModule,
modelingModule modelingModule,
autoPlaceModule
] ]
})); }));
@ -114,6 +116,29 @@ describe('features - label-editing', function() {
)); ));
it('should complete on auto place', inject(
function(elementRegistry, directEditing, elementFactory, autoPlace) {
// given
var shape = elementRegistry.get('Task_1'),
task = shape.businessObject;
directEditing.activate(shape);
directEditing._textbox.content.textContent = 'FOO BAR';
// when
autoPlace.append(shape, elementFactory.create(
'shape',
{ type: 'bpmn:ServiceTask' }
));
// then
expect(task.name).to.equal('FOO BAR');
}
));
it('should submit on root element click', inject( it('should submit on root element click', inject(
function(elementRegistry, directEditing, canvas, eventBus) { function(elementRegistry, directEditing, canvas, eventBus) {
@ -147,7 +172,7 @@ describe('features - label-editing', function() {
describe('details', function() { describe('details', function() {
beforeEach(bootstrapViewer(diagramXML, { beforeEach(bootstrapModeler(diagramXML, {
modules: [ modules: [
labelEditingModule, labelEditingModule,
coreModule, coreModule,
@ -371,7 +396,7 @@ describe('features - label-editing', function() {
describe('sizes', function() { describe('sizes', function() {
beforeEach(bootstrapViewer(diagramXML, { beforeEach(bootstrapModeler(diagramXML, {
modules: [ modules: [
labelEditingModule, labelEditingModule,
coreModule, coreModule,