diff --git a/src/js/index.js b/src/js/index.js index 13974ae38..9073feea5 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -595,11 +595,13 @@ app.directive('tagInput', function () { }); }; $scope.addTag = function () { - var tagArray; - if ($scope.tagText.length === 0) { - return; + var tagArray = $scope.tagArray(); + + // prevent adding empty or existing items + if ($scope.tagText.length === 0 || tagArray.indexOf($scope.tagText) !== -1) { + return $scope.tagText = ''; } - tagArray = $scope.tagArray(); + tagArray.push($scope.tagText); $scope.inputTags = tagArray.join(','); return $scope.tagText = '';