Skip to content
This repository has been archived by the owner on Nov 22, 2021. It is now read-only.

Fixes bug on Android/Chrome because Android does not sends the correct keyCode #692

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 3.1.2 (2016-07-03)

#### Bug Fixes

Fixes bug with comma detection on android/chrome.

## 3.1.1 (2016-05-27)

#### Bug Fixes
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
},
"name": "ng-tags-input",
"prettyName": "ngTagsInput",
"version": "3.1.1",
"version": "3.1.3",
"description": "Tags input directive for AngularJS",
"license": "MIT",
"homepage": "http://mbenford.github.io/ngTagsInput",
"repository": {
"type": "git",
"url": "https://github.com/mbenford/ngTagsInput.git"
"url": "https://github.com/lambdasistemas/ngTagsInput.git"
},
"bugs": {
"url": "https://github.com/mbenford/ngTagsInput/issues"
Expand Down
13 changes: 9 additions & 4 deletions src/tags-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,12 @@ tagsInput.directive('tagsInput', function($timeout, $document, $window, $q, tags
.on('input-keydown', function(event) {
var key = event.keyCode,
addKeys = {},
shouldAdd, shouldRemove, shouldSelect, shouldEditLastTag;
shouldAdd, shouldRemove, shouldSelect, shouldEditLastTag,
newTagText = scope.newTag.text();
if ((event.keyCode === 229) && (scope.text !== undefined) && (scope.text[newTagText.length -1] === ',')) {
key = KEYS.comma;
newTagText = newTagText.slice(0, -1); // Remove comma
}

if (tiUtil.isModifierOn(event) || hotkeys.indexOf(key) === -1) {
return;
Expand All @@ -423,11 +428,11 @@ tagsInput.directive('tagsInput', function($timeout, $document, $window, $q, tags

shouldAdd = !options.addFromAutocompleteOnly && addKeys[key];
shouldRemove = (key === KEYS.backspace || key === KEYS.delete) && tagList.selected;
shouldEditLastTag = key === KEYS.backspace && scope.newTag.text().length === 0 && options.enableEditingLastTag;
shouldSelect = (key === KEYS.backspace || key === KEYS.left || key === KEYS.right) && scope.newTag.text().length === 0 && !options.enableEditingLastTag;
shouldEditLastTag = key === KEYS.backspace && newTagText.length === 0 && options.enableEditingLastTag;
shouldSelect = (key === KEYS.backspace || key === KEYS.left || key === KEYS.right) && newTagText.length === 0 && !options.enableEditingLastTag;

if (shouldAdd) {
tagList.addText(scope.newTag.text());
tagList.addText(newTagText);
}
else if (shouldEditLastTag) {
tagList.selectPrior();
Expand Down