From 407a191f7e76724ef75a472adef732711069be98 Mon Sep 17 00:00:00 2001 From: Philipp Fromme Date: Mon, 29 Apr 2024 11:44:01 +0200 Subject: [PATCH] fix(context-pad): remove append preview on context pad close Closes #2150 --- .../context-pad/ContextPadProvider.js | 8 +++---- .../context-pad/ContextPadProviderSpec.js | 23 +++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/lib/features/context-pad/ContextPadProvider.js b/lib/features/context-pad/ContextPadProvider.js index b33a1b2c69..be5554d028 100644 --- a/lib/features/context-pad/ContextPadProvider.js +++ b/lib/features/context-pad/ContextPadProvider.js @@ -110,6 +110,10 @@ export default function ContextPadProvider( entries.replace.action.click(event, shape); } }); + + eventBus.on('contextPad.close', function() { + appendPreview.cleanUp(); + }); } ContextPadProvider.$inject = [ @@ -244,16 +248,12 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) { create.start(event, shape, { source: element }); - - appendPreview.cleanUp(); } var append = autoPlace ? function(_, element) { var shape = elementFactory.createShape(assign({ type: type }, options)); autoPlace.append(element, shape); - - appendPreview.cleanUp(); } : appendStart; var previewAppend = autoPlace ? function(_, element) { diff --git a/test/spec/features/context-pad/ContextPadProviderSpec.js b/test/spec/features/context-pad/ContextPadProviderSpec.js index 530557a856..45d8553d91 100644 --- a/test/spec/features/context-pad/ContextPadProviderSpec.js +++ b/test/spec/features/context-pad/ContextPadProviderSpec.js @@ -737,6 +737,29 @@ describe('features - context-pad', function() { expect(domQueryAll('.djs-dragger', canvas.getLayer('complex-preview'))).to.have.length(2); })); + + it('should remove append preview on close', inject(function(canvas, elementRegistry, contextPad) { + + // given + var element = elementRegistry.get('Task_1'); + + contextPad.open(element); + + // mock event + var event = padEvent('append.gateway'); + + contextPad.trigger('hover', event); + + expect(canvas.getLayer('complex-preview')).to.exist; + expect(domQueryAll('.djs-dragger', canvas.getLayer('complex-preview'))).to.have.length(2); + + // when + contextPad.close(); + + // then + expect(domQueryAll('.djs-dragger', canvas.getLayer('complex-preview'))).to.have.length(0); + })); + }); });