Skip to content

Commit

Permalink
Fix: backspace/del not working as expected in tagbox
Browse files Browse the repository at this point in the history
  • Loading branch information
setaou committed Jan 28, 2016
1 parent a1b200a commit eaea935
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions js/tagbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,20 @@ tagbox.directive('tagbox', function() {
scope.data = "";
event.preventDefault();
}
else if ((event.key == "Backspace" || event.key == "Delete") && input[0].selectionStart == 0)
else if (event.key == "Backspace" && input[0].selectionStart == 0 && input[0].selectionEnd == input[0].selectionStart)
{
if (scope.selectedtag >= 0) {
scope.removeTagByIndex(scope.selectedtag, event.key == "Backspace");
scope.removeTagByIndex(scope.selectedtag, true);
} else {
scope.removeTagByIndex(scope.tags.length - 1);
}
event.preventDefault();
}
else if (event.key == "Delete" && scope.selectedtag >= 0)
{
scope.removeTagByIndex(scope.selectedtag);
event.preventDefault();
}
else if (event.key == "ArrowLeft" && input[0].selectionStart == 0)
{
if (scope.selectedtag == -1) {
Expand Down

0 comments on commit eaea935

Please sign in to comment.