From a4630814584ae4cb4cc64e0dea11954e27b81bfc Mon Sep 17 00:00:00 2001 From: Blackbaud-PatrickOFriel Date: Tue, 15 Dec 2015 13:16:08 -0500 Subject: [PATCH] filedrop enter press #156 --- js/sky/src/fileattachments/filedrop.js | 3 ++- .../src/fileattachments/test/filedrop.spec.js | 24 +++++++++++++++++++ .../templates/fileattachments/filedrop.html | 4 ++-- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/js/sky/src/fileattachments/filedrop.js b/js/sky/src/fileattachments/filedrop.js index af75acef..d3285a7e 100644 --- a/js/sky/src/fileattachments/filedrop.js +++ b/js/sky/src/fileattachments/filedrop.js @@ -19,7 +19,8 @@ scope.bbFileDrop = { hasTranscludeContents: $.trim(el.find('.bb-file-drop-contents-custom').html()).length > 0, allowLinks: angular.isDefined(attrs.bbFileDropLink), - addLink: function () { + addLink: function ($event) { + $event.preventDefault(); scope.bbFileDropLinkChange({ link: { url: scope.bbFileDrop.url diff --git a/js/sky/src/fileattachments/test/filedrop.spec.js b/js/sky/src/fileattachments/test/filedrop.spec.js index 970bc78c..36b5239f 100644 --- a/js/sky/src/fileattachments/test/filedrop.spec.js +++ b/js/sky/src/fileattachments/test/filedrop.spec.js @@ -429,4 +429,28 @@ describe('File drop directive', function () { el.remove(); nonTargetEl.remove(); }); + + it('should call event prevent default on enter', function () { + var $scope = $rootScope.$new(), + el, + $event, + isolateScope; + + $event = jasmine.createSpyObj('$event', ['preventDefault']); + + $scope.addLink = angular.noop; + + el = getDropWithLinkEl($scope); + + // The element has to be in the DOM to trigger its change event in Firefox. + el.appendTo(document.body); + + isolateScope = el.isolateScope(); + + isolateScope.bbFileDrop.addLink($event); + + expect($event.preventDefault).toHaveBeenCalled(); + + el.remove(); + }); }); diff --git a/js/sky/templates/fileattachments/filedrop.html b/js/sky/templates/fileattachments/filedrop.html index 2f5af673..7159f9bf 100644 --- a/js/sky/templates/fileattachments/filedrop.html +++ b/js/sky/templates/fileattachments/filedrop.html @@ -35,10 +35,10 @@