From 482213eceeeea5e2c5c8388bc76e3f83f50a2379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=B0=D0=BB=D1=83=D0=B5=D0=B2=20=D0=9E=D0=BB=D0=B5?= =?UTF-8?q?=D0=B3=20=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B8=D1=87?= Date: Fri, 18 Jan 2019 13:14:32 +0300 Subject: [PATCH] Fixed repeated focusing when clicking on the input --- jquery.flexselect.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/jquery.flexselect.js b/jquery.flexselect.js index 6f8105b..3bdd4ab 100644 --- a/jquery.flexselect.js +++ b/jquery.flexselect.js @@ -44,6 +44,7 @@ allowMouseMove: true, dropdownMouseover: false, // Workaround for poor IE behaviors indexOptgroupLabels: false, + isFocused: false, init: function(select, options) { this.settings = $.extend({}, this.settings, options); @@ -93,8 +94,10 @@ var self = this; this.input.click(function() { - self.lastAbbreviation = null; - self.focus(); + if (!self.isFocused) { + self.lastAbbreviation = null; + self.focus(); + } }); this.input.mouseup(function(event) { @@ -106,6 +109,7 @@ self.abbreviationBeforeFocus = self.input.val(); self.input[0].setSelectionRange(0, self.input.val().length); if (!self.picked) self.filterResults(); + self.isFocused = true; }); this.input.blur(function() { @@ -115,6 +119,7 @@ self.setValue(''); else if (!self.settings.allowMismatch && !self.picked) self.reset(); + self.isFocused = false; } });