From 4dbf57f2d3cae1de5074f7572ad0639f1a089777 Mon Sep 17 00:00:00 2001 From: Kate von Roeder Date: Tue, 14 Jan 2014 13:17:06 -0800 Subject: [PATCH] Enable Escape key to close tag suggestion popup closes #1893 - Checking the contents of search term after evaluating the keycode caused the suggestion box to be hidden and immediately reshown - Moving the if/else to the top of the function enables us to fix the issue without complicating the suggestion update logic --- core/client/views/editor-tag-widget.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/client/views/editor-tag-widget.js b/core/client/views/editor-tag-widget.js index 053e30bb5758..45daac0c1b5e 100644 --- a/core/client/views/editor-tag-widget.js +++ b/core/client/views/editor-tag-widget.js @@ -134,6 +134,12 @@ 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")) { @@ -159,12 +165,6 @@ if (e.keyCode === this.keys.UP || e.keyCode === this.keys.DOWN) { return false; } - - if (searchTerm) { - this.showSuggestions($target, searchTerm); - } else { - this.$suggestions.hide(); - } }, handleKeydown: function (e) {