From 58607bec93b59d85e8727d9779d73d8267e59c8b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Robert=20Stojni=C4=87?= Date: Mon, 4 May 2009 21:07:18 +0000 Subject: [PATCH] Fix annoying bug with mwsuggest that makes it shown suggestions after search box has lost focus (which it shouldn't). Introduce additional attribute that tells the suggestion container that it should stay hidden. --- includes/DefaultSettings.php | 2 +- skins/common/mwsuggest.js | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index fc6424ee02..bd71fc5599 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1477,7 +1477,7 @@ $wgCacheEpoch = '20030516000000'; * to ensure that client-side caches don't keep obsolete copies of global * styles. */ -$wgStyleVersion = '217'; +$wgStyleVersion = '218'; # Server-side caching: diff --git a/skins/common/mwsuggest.js b/skins/common/mwsuggest.js index 061a645149..503c739246 100644 --- a/skins/common/mwsuggest.js +++ b/skins/common/mwsuggest.js @@ -78,6 +78,7 @@ function os_Results(name, formname){ this.containerRow = 0; // height of result field in the container this.containerTotal = 0; // total height of the container will all results this.visible = false; // if container is visible + this.stayHidden = false; // don't try to show if lost focus } /** Hide results div */ @@ -93,6 +94,8 @@ function os_hideResults(r){ function os_showResults(r){ if(os_is_stopped) return; + if(r.stayHidden) + return os_fitContainer(r); var c = document.getElementById(r.container); r.selected = -1; @@ -442,6 +445,7 @@ function os_delayedFetch(){ /** Init timed update via os_delayedUpdate() */ function os_fetchResults(r, query, timeout){ if(query == ""){ + r.query = ""; os_hideResults(r); return; } else if(query == r.query) @@ -622,13 +626,19 @@ function os_eventBlur(e){ var r = os_map[targ.id]; if(r == null) return; // not our event - if(!os_mouse_pressed) + if(!os_mouse_pressed){ os_hideResults(r); + r.stayHidden = true + } } /** Event: focus (catch only when stopped) */ function os_eventFocus(e){ - // nothing happens here? + var targ = os_getTarget(e); + var r = os_map[targ.id]; + if(r == null) + return; // not our event + r.stayHidden = false } -- 2.20.1