diff --git a/src/pretix/static/pretixcontrol/js/ui/typeahead.js b/src/pretix/static/pretixcontrol/js/ui/typeahead.js
index 648b86256..c11a14ad2 100644
--- a/src/pretix/static/pretixcontrol/js/ui/typeahead.js
+++ b/src/pretix/static/pretixcontrol/js/ui/typeahead.js
@@ -14,6 +14,7 @@ $(function () {
var lastQuery = null;
var runQueryTimeout = null;
var loadIndicatorTimeout = null;
+ var focusOutTimeout = null;
function showLoadIndicator() {
$container.find("li:not(.query-holder)").remove();
$container.append("
");
@@ -76,14 +77,7 @@ $(function () {
$("").append(
$("").attr("href", res.url).append(
$linkContent
- ).on("mousedown", function (event) {
- if ($(this).length) {
- location.href = $(this).attr("href");
- }
- $(this).parent().addClass("active");
- event.preventDefault();
- event.stopPropagation();
- })
+ )
)
);
});
@@ -115,8 +109,17 @@ $(function () {
event.stopPropagation();
}
});
- $query.on("blur", function (event) {
- $container.removeClass('focused');
+ $container.add($query).on("keydown", function (event) {
+ if (event.which === 27) { // escape
+ $container.removeClass('focused');
+ }
+ }).on("focusin", function (event) {
+ window.clearTimeout(focusOutTimeout);
+ $(document.body).one("focusout", function (event) {
+ focusOutTimeout = window.setTimeout(function () {
+ $container.removeClass('focused');
+ }, 100);
+ })
});
$query.on("keyup", function (event) {
var $first = $container.find("li:not(.query-holder)").first();