From: MatmaRex Date: Sat, 9 Feb 2013 18:53:19 +0000 (+0100) Subject: $.suggestions: make it possible to re-show suggestions X-Git-Tag: 1.31.0-rc.0~20709^2 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=65017a8516c321b47d97f1e0b154d3a9d9b7fd8a;p=lhc%2Fweb%2Fwiklou.git $.suggestions: make it possible to re-show suggestions This patch makes it possible to re-show suggestions after they were hidden (by pressing Escape) by simply pressing the down arrow. This seems to have been the intended behavior to begin with (given how update() is called on down-arrow press when the suggestions list is hidden), but someone borked the implementation. To reproduce the behavior: * type something in and wait for the suggestions to appear * press Escape, hiding the suggestion list * press down arrow to fetch and show it again Change-Id: Ic8aa162d2f0701d93329de855bd8b7dbdb99f979 --- diff --git a/resources/jquery/jquery.suggestions.js b/resources/jquery/jquery.suggestions.js index 303b18f1c5..3448b7a61c 100644 --- a/resources/jquery/jquery.suggestions.js +++ b/resources/jquery/jquery.suggestions.js @@ -79,13 +79,16 @@ $.suggestions = { * @param {Boolean} delayed Whether or not to delay this by the currently configured amount of time */ update: function ( context, delayed ) { - // Only fetch if the value in the textbox changed and is not empty + // Only fetch if the value in the textbox changed and is not empty, or if the results were hidden // if the textbox is empty then clear the result div, but leave other settings intouched function maybeFetch() { if ( context.data.$textbox.val().length === 0 ) { context.data.$container.hide(); context.data.prevText = ''; - } else if ( context.data.$textbox.val() !== context.data.prevText ) { + } else if ( + context.data.$textbox.val() !== context.data.prevText || + !context.data.$container.is( ':visible' ) + ) { if ( typeof context.config.fetch === 'function' ) { context.data.prevText = context.data.$textbox.val(); context.config.fetch.call( context.data.$textbox, context.data.$textbox.val() );