From 254a944d7a3f27a5b8b8094f399faa0eb04b1eb3 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Thu, 31 Mar 2016 10:34:24 -0700 Subject: [PATCH] [Firefox] Invoke preventDefault on drop ...such that Firefox does not try to treat drop as a new URL to navigate to. Addresses #688 and #527 --- .../features/timeline/src/directives/MCTSwimlaneDrop.js | 1 + .../timeline/test/directives/MCTSwimlaneDropSpec.js | 5 +++++ platform/representation/src/gestures/DropGesture.js | 1 + platform/representation/test/gestures/DropGestureSpec.js | 7 ++++++- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/platform/features/timeline/src/directives/MCTSwimlaneDrop.js b/platform/features/timeline/src/directives/MCTSwimlaneDrop.js index 0692062cc6..704444c41c 100644 --- a/platform/features/timeline/src/directives/MCTSwimlaneDrop.js +++ b/platform/features/timeline/src/directives/MCTSwimlaneDrop.js @@ -91,6 +91,7 @@ define( if (id) { event.stopPropagation(); + e.preventDefault(); // Delegate the drop to the swimlane itself swimlane.drop(id, droppedObject); } diff --git a/platform/features/timeline/test/directives/MCTSwimlaneDropSpec.js b/platform/features/timeline/test/directives/MCTSwimlaneDropSpec.js index 27fb6d6dbb..aea4da18df 100644 --- a/platform/features/timeline/test/directives/MCTSwimlaneDropSpec.js +++ b/platform/features/timeline/test/directives/MCTSwimlaneDropSpec.js @@ -162,6 +162,11 @@ define( expect(mockScope.$apply).toHaveBeenCalled(); }); + it("invokes preventDefault on drop", function () { + handlers.drop(testEvent); + expect(testEvent.preventDefault).toHaveBeenCalled(); + }); + it("clears highlights when drag leaves", function () { mockSwimlane.highlight.andReturn(true); handlers.dragleave(); diff --git a/platform/representation/src/gestures/DropGesture.js b/platform/representation/src/gestures/DropGesture.js index 1e884c14f7..b1d1dd456c 100644 --- a/platform/representation/src/gestures/DropGesture.js +++ b/platform/representation/src/gestures/DropGesture.js @@ -123,6 +123,7 @@ define( // destination domain object's composition, and persist // the change. if (id) { + e.preventDefault(); $q.when(action && action.perform()).then(function (result) { //Don't go into edit mode for folders if (domainObjectType!=='folder') { diff --git a/platform/representation/test/gestures/DropGestureSpec.js b/platform/representation/test/gestures/DropGestureSpec.js index 9f24ee066a..52327792ab 100644 --- a/platform/representation/test/gestures/DropGestureSpec.js +++ b/platform/representation/test/gestures/DropGestureSpec.js @@ -194,6 +194,11 @@ define( ); }); + it("invokes preventDefault on drop", function () { + callbacks.drop(mockEvent); + expect(mockEvent.preventDefault).toHaveBeenCalled(); + }); + }); } -); \ No newline at end of file +);