diff --git a/build/ng-tags-input.js b/build/ng-tags-input.js index e9d93ac8..b3b861e8 100644 --- a/build/ng-tags-input.js +++ b/build/ng-tags-input.js @@ -198,7 +198,7 @@ tagsInput.directive('tagsInput', ["$timeout","$document","tagsInputConfig", func return; } - if (hotkeys.indexOf(e.keyCode) === -1) { + if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || hotkeys.indexOf(e.keyCode) === -1) { return; } @@ -248,6 +248,7 @@ tagsInput.directive('tagsInput', ["$timeout","$document","tagsInputConfig", func }; }]); + /** * @ngdoc directive * @name tagsInput.directive:autoComplete diff --git a/build/ng-tags-input.min.zip b/build/ng-tags-input.min.zip index efb9a46c..192720f7 100644 Binary files a/build/ng-tags-input.min.zip and b/build/ng-tags-input.min.zip differ diff --git a/build/ng-tags-input.zip b/build/ng-tags-input.zip index 975ba99e..885a19a4 100644 Binary files a/build/ng-tags-input.zip and b/build/ng-tags-input.zip differ diff --git a/src/tags-input.js b/src/tags-input.js index e34242ca..2f5223bb 100644 --- a/src/tags-input.js +++ b/src/tags-input.js @@ -186,7 +186,7 @@ tagsInput.directive('tagsInput', function($timeout, $document, tagsInputConfig) return; } - if (hotkeys.indexOf(e.keyCode) === -1) { + if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || hotkeys.indexOf(e.keyCode) === -1) { return; } @@ -234,4 +234,4 @@ tagsInput.directive('tagsInput', function($timeout, $document, tagsInputConfig) }); } }; -}); \ No newline at end of file +}); diff --git a/test/tags-input.spec.js b/test/tags-input.spec.js index 963a0f0c..7829d674 100644 --- a/test/tags-input.spec.js +++ b/test/tags-input.spec.js @@ -43,15 +43,19 @@ describe('tags-input-directive', function() { function newTag(tag, key) { key = key || KEYS.enter; - for(var i = 0; i < tag.length; i++) { - sendKeyPress(tag.charCodeAt(i)); - } + sendKeyPresses(tag); sendKeyDown(key); } - function sendKeyPress(charCode) { + function sendKeyPresses(str) { + for(var i = 0; i < str.length; i++) { + sendKeyPress(str.charCodeAt(i)); + } + } + + function sendKeyPress(charCode, eventProps) { var input = getInput(); - var event = jQuery.Event('keypress', { charCode: charCode }); + var event = jQuery.Event('keypress', jQuery.extend({}, eventProps||{}, { charCode: charCode })); input.trigger(event); if (!event.isDefaultPrevented()) { @@ -964,4 +968,20 @@ describe('tags-input-directive', function() { expect(autocompleteObj.getTags()).toEqual(['a', 'b', 'c']); }); }); -}); \ No newline at end of file + + describe('key presses with modifiers do not trigger hotkeys', function() { + it('allows shift-comma to enter a left angle character', function() { + // Arrange + compile('add-on-comma="true"'); + + // Act + sendKeyPresses('Testing '); + sendKeyPress(',', {shiftKey: true}); + sendKeyPresses('test>'); + sendKeyDown(KEYS.comma); + + // Assert + expect($scope.tags).toEqual(['Testing ']); + }); + }); +});