From c0a5c800e03a39e573bf2a2a11980feb53c8dd87 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sun, 30 Nov 2014 13:05:31 +0100 Subject: [PATCH] Fixed autocomplete staying even after hiding input --- public_html/js/Controls/AutoCompleteInput.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/public_html/js/Controls/AutoCompleteInput.js b/public_html/js/Controls/AutoCompleteInput.js index 46b3d063..27bc20ad 100644 --- a/public_html/js/Controls/AutoCompleteInput.js +++ b/public_html/js/Controls/AutoCompleteInput.js @@ -24,6 +24,7 @@ App.Controls.AutoCompleteInput = function($input) { var cachedSource = null; var results = []; var activeResult = -1; + var monitorInputHidingInterval = null; if ($input.length === 0) { throw new Error('Input element was not found'); @@ -134,6 +135,7 @@ App.Controls.AutoCompleteInput = function($input) { function hide() { $div.hide(); + window.clearInterval(monitorInputHidingInterval); } function selectPrevious() { @@ -232,6 +234,7 @@ App.Controls.AutoCompleteInput = function($input) { top: ($input.offset().top + $input.outerHeight() - 2) + 'px', }); $div.show(); + monitorInputHiding(); } function refreshActiveResult() { @@ -241,5 +244,13 @@ App.Controls.AutoCompleteInput = function($input) { } } + function monitorInputHiding() { + monitorInputHidingInterval = window.setInterval(function() { + if (!$input.is(':visible')) { + hide(); + } + }, 100); + } + return options; };