diff --git a/lib/features/drilldown/DrilldownOverlayBehavior.js b/lib/features/drilldown/DrilldownOverlayBehavior.js index 97339f8f..7d6b690a 100644 --- a/lib/features/drilldown/DrilldownOverlayBehavior.js +++ b/lib/features/drilldown/DrilldownOverlayBehavior.js @@ -142,6 +142,11 @@ DrilldownOverlayBehavior.prototype.addOverlay = function(element) { var canvas = this._canvas; var overlays = this._overlays; + var existingOverlays = overlays.get({ element: element, type: 'drilldown' }); + if (existingOverlays.length) { + this.removeOverlay(element); + } + var button = domify(''); button.addEventListener('click', function() { diff --git a/test/spec/features/drilldown/DrilldownOverlaysBehaviorSpec.js b/test/spec/features/drilldown/DrilldownOverlaysBehaviorSpec.js index 7099d6f7..fe83dc72 100644 --- a/test/spec/features/drilldown/DrilldownOverlaysBehaviorSpec.js +++ b/test/spec/features/drilldown/DrilldownOverlaysBehaviorSpec.js @@ -388,4 +388,19 @@ describe('features/modeling/behavior - subprocess planes', function() { }); + + it('should only show one overlay', inject(function(elementRegistry, overlays, modeling) { + + // given + var filledSubProcess = elementRegistry.get('Subprocess_with_content'); + var emptySubProcessPlane = elementRegistry.get('Subprocess_empty_plane'); + + // when + modeling.moveShape(filledSubProcess, { x: 0, y: 0 }, emptySubProcessPlane); + + // then + var elementOverlays = overlays.get({ element: filledSubProcess }); + expect(elementOverlays).to.have.lengthOf(1); + })); + });