Visibility problems with preserveInput=true
If preserveInput is enabled there is a problem that occurs (happens in all mayor browsers).
Reproduce: Bug A)
- Select a suggestion item with the mouse -> The textfield loses focus and the suggestion list disappears
- Click the textfield again -> Bug: The suggestions box shows up and after a few milliseconds it disappears again
Bug B)
- Select a suggestion item with the arrow keys and press return -> Bug: The suggestions list disappears and after a few milliseconds it is shown again.
Bug A and B probably result from the same code. It must have something to do the killerFn().
A partial fix would be:
--- jquery.autocomplete.js 2015-03-14 21:22:50.000000000 +0100
+++ jquery.autocomplete2.js 2015-03-15 00:31:32.000000000 +0100
@@ -147,7 +147,7 @@
that.element.setAttribute('autocomplete', 'off');
that.killerFn = function (e) {
- if ($(e.target).closest('.' + that.options.containerClass).length === 0) {
+ if ($(e.target).closest('.' + that.options.containerClass).length === 0 && !that.options.preserveInput) {
that.killSuggestions();
that.disableKillerFn();
}
But that only fixes Bug A and is causes new problems (the textfield doesn't lose focus when outside is clicked).
Probably I'll do a pull request later, but as a quick fix you can try it now:
Fix bug A
@@ line 325
enableKillerFn: function () {
var that = this;
- $(document).on('click.autocomplete', that.killerFn);
+ $(document).one('click.autocomplete', that.killerFn);
},
Fix bug B
@@ line 433
case keys.DOWN:
+ case keys.RETURN:
return;
case keys.RETURN:
Hi,
For fix bug B, ill recommend that adding the line "that.killerFn(e);" in the "case keys.Return:"
case keys.RETURN: if (that.selectedIndex === -1) { that.hide(); return; } that.select(that.selectedIndex); that.killerFn(e); <--- line added
The reason I added this line and has fixed bug B, its because this function is called after clicking a suggestion, but its not called while key pressing.
Hi,
I'm facing bug B as well.
Could you please take a look on it?
No news about this issue ? I'm also having problem B
Hello,
I haven't seen any update or release regarding this bug.
Have you tried using the "workaround" I suggested?
The killerFn() doesn't exists anymore.
In my case I think the problem appears because I change the input value after the user select something, so somehow Autocomplete think it's a different value. It works with the TAB because there is a return.
Then you almost got your problem solved. What I did on the time I worked on it, was to see how it worked in both scenarios. Saying that, see what part of the TAB scenarios is doing the expected behavior.
Hope it works.
Any fix to this issue yet? Seeing this still.