Skip to content

Commit e712ce8

Browse files
committed
fixes #253
1 parent a30c9d1 commit e712ce8

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

dist/jQuery.tagify.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/tagify.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/tagify.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,8 @@ Tagify.prototype = {
11851185
},
11861186
callbacks: {
11871187
onKeyDown: function onKeyDown(e) {
1188+
var _this6 = this;
1189+
11881190
// get the "active" element, and if there was none (yet) active, use first child
11891191
var activeListElm = this.DOM.dropdown.querySelector("[class$='--active']"),
11901192
selectedElm = activeListElm || this.DOM.dropdown.children[0],
@@ -1221,6 +1223,9 @@ Tagify.prototype = {
12211223
newValue = this.suggestedListItems[this.getNodeIndex(activeListElm)] || this.input.value;
12221224
this.addTags([newValue], true);
12231225
this.dropdown.hide.call(this);
1226+
setTimeout(function () {
1227+
return _this6.DOM.input.focus();
1228+
}, 100);
12241229
return false;
12251230
}
12261231

@@ -1231,35 +1236,30 @@ Tagify.prototype = {
12311236
if (e.target.className.includes('__item')) this.dropdown.highlightOption.call(this, e.target);
12321237
},
12331238
onClick: function onClick(e) {
1234-
var _this6 = this;
1235-
1236-
var onClickOutside = function onClickOutside() {
1237-
return _this6.dropdown.hide.call(_this6);
1238-
},
1239-
value,
1240-
listItemElm;
1239+
var _this7 = this;
12411240

1241+
var value, listItemElm;
12421242
if (e.button != 0 || e.target == this.DOM.dropdown) return; // allow only mouse left-clicks
12431243

1244-
if (e.target == document.documentElement) return onClickOutside();
12451244
listItemElm = e.target.closest(".tagify__dropdown__item");
12461245

12471246
if (listItemElm) {
12481247
value = this.suggestedListItems[this.getNodeIndex(listItemElm)] || this.input.value;
12491248
this.addTags([value], true);
1250-
this.dropdown.hide.call(this);
12511249
setTimeout(function () {
1252-
return _this6.DOM.input.focus();
1250+
return _this7.DOM.input.focus();
12531251
}, 100);
1254-
} // clicked outside the dropdown, so just close it
1255-
else onClickOutside();
1252+
}
1253+
1254+
this.dropdown.hide.call(this);
12561255
}
12571256
}
12581257
},
12591258
highlightOption: function highlightOption(elm, adjustScroll) {
12601259
if (!elm) return;
12611260
var className = "tagify__dropdown__item--active",
12621261
value;
1262+
elm.focus();
12631263
this.DOM.dropdown.querySelectorAll("[class$='--active']").forEach(function (activeElm) {
12641264
activeElm.classList.remove(className);
12651265
activeElm.removeAttribute("aria-selected");
@@ -1280,7 +1280,7 @@ Tagify.prototype = {
12801280
* @return {[type]} [description]
12811281
*/
12821282
filterListItems: function filterListItems(value) {
1283-
var _this7 = this;
1283+
var _this8 = this;
12841284

12851285
var list = [],
12861286
whitelist = this.settings.whitelist,
@@ -1294,7 +1294,7 @@ Tagify.prototype = {
12941294

12951295
if (!value) {
12961296
return whitelist.filter(function (item) {
1297-
return _this7.isTagDuplicate(item.value || item) == -1;
1297+
return _this8.isTagDuplicate(item.value || item) == -1;
12981298
}) // don't include tags which have already been added.
12991299
.slice(0, suggestionsCount); // respect "maxItems" dropdown setting
13001300
}

dist/tagify.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tagify.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,7 @@ Tagify.prototype = {
12741274
newValue = this.suggestedListItems[this.getNodeIndex(activeListElm)] || this.input.value;
12751275
this.addTags( [newValue], true );
12761276
this.dropdown.hide.call(this);
1277+
setTimeout(() => this.DOM.input.focus(), 100);
12771278
return false;
12781279
}
12791280
}
@@ -1286,25 +1287,21 @@ Tagify.prototype = {
12861287
},
12871288

12881289
onClick(e){
1289-
var onClickOutside = () => this.dropdown.hide.call(this),
1290-
value,
1290+
var value,
12911291
listItemElm;
12921292

12931293
if( e.button != 0 || e.target == this.DOM.dropdown ) return; // allow only mouse left-clicks
1294-
if( e.target == document.documentElement ) return onClickOutside();
12951294

12961295
listItemElm = e.target.closest(".tagify__dropdown__item");
12971296

12981297
if( listItemElm ){
12991298
value = this.suggestedListItems[this.getNodeIndex(listItemElm)] || this.input.value;
13001299
this.addTags([value], true);
1301-
this.dropdown.hide.call(this);
1300+
13021301
setTimeout(() => this.DOM.input.focus(), 100);
13031302
}
13041303

1305-
// clicked outside the dropdown, so just close it
1306-
else
1307-
onClickOutside();
1304+
this.dropdown.hide.call(this);
13081305
}
13091306
}
13101307
},
@@ -1315,6 +1312,8 @@ Tagify.prototype = {
13151312
var className = "tagify__dropdown__item--active",
13161313
value;
13171314

1315+
elm.focus();
1316+
13181317
this.DOM.dropdown.querySelectorAll("[class$='--active']").forEach(activeElm => {
13191318
activeElm.classList.remove(className)
13201319
activeElm.removeAttribute("aria-selected")

src/tagify.scss

+1
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@
343343
cursor: pointer;
344344
border-radius: 3px;
345345
position: relative;
346+
outline:none;
346347

347348
&--active{ background:$tag-bg; }
348349
&:active{ background:lighten($tag-bg, 5); }

0 commit comments

Comments
 (0)