diff --git a/core/client/views/editor-tag-widget.js b/core/client/views/editor-tag-widget.js
index 45daac0c1b..33d3b7226a 100644
--- a/core/client/views/editor-tag-widget.js
+++ b/core/client/views/editor-tag-widget.js
@@ -125,7 +125,7 @@
/*jslint regexp: true */ // - would like to remove this
highlightedName = highlightedName.replace(/([^<>]*)((<[^>]+>)+)([^<>]*<\/mark>)/, "$1$2$4");
- suggestionHTML = "" + highlightedName + "";
+ suggestionHTML = "" + highlightedName + "";
this.$suggestions.append(suggestionHTML);
}, this);
},
@@ -134,12 +134,6 @@
var $target = $(e.currentTarget),
searchTerm = $.trim($target.val());
- if (searchTerm) {
- this.showSuggestions($target, searchTerm);
- } else {
- this.$suggestions.hide();
- }
-
if (e.keyCode === this.keys.UP) {
e.preventDefault();
if (this.$suggestions.is(":visible")) {
@@ -160,6 +154,12 @@
}
} else if (e.keyCode === this.keys.ESC) {
this.$suggestions.hide();
+ } else {
+ if (searchTerm) {
+ this.showSuggestions($target, searchTerm);
+ } else {
+ this.$suggestions.hide();
+ }
}
if (e.keyCode === this.keys.UP || e.keyCode === this.keys.DOWN) {
@@ -195,8 +195,8 @@
$selectedSuggestion = this.$suggestions.children(".selected");
if (this.$suggestions.is(":visible") && $selectedSuggestion.length !== 0) {
- if ($('.tag:containsExact("' + $selectedSuggestion.data('tag-name') + '")').length === 0) {
- tag = {id: $selectedSuggestion.data('tag-id'), name: $selectedSuggestion.data('tag-name')};
+ if ($('.tag:containsExact("' + _.unescape($selectedSuggestion.data('tag-name')) + '")').length === 0) {
+ tag = {id: $selectedSuggestion.data('tag-id'), name: _.unescape($selectedSuggestion.data('tag-name'))};
this.addTag(tag);
}
} else {
@@ -232,7 +232,7 @@
handleSuggestionClick: function (e) {
var $target = $(e.currentTarget);
if (e) { e.preventDefault(); }
- this.addTag({id: $target.data('tag-id'), name: $target.data('tag-name')});
+ this.addTag({id: $target.data('tag-id'), name: _.unescape($target.data('tag-name'))});
},
handleTagClick: function (e) {