summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladislav Zarakovsky <vlad.zar@gmail.com>2016-01-08 11:22:24 +0300
committerVladislav Zarakovsky <vlad.zar@gmail.com>2016-01-08 11:22:24 +0300
commit91d613f208658861e975917162e2e3cee84d512a (patch)
tree2caf0177af7bfb04aaee35d6c292702c6d6d51db
parentc69149e7adb01f8e646ea94708cdba6215136e33 (diff)
downloadawesomplete-91d613f208658861e975917162e2e3cee84d512a.zip
awesomplete-91d613f208658861e975917162e2e3cee84d512a.tar.gz
awesomplete-91d613f208658861e975917162e2e3cee84d512a.tar.bz2
Fix #16808. Input loses focus if item selected with mouse.
-rw-r--r--awesomplete.js1
-rw-r--r--test/events/mousedownSpec.js3
2 files changed, 3 insertions, 1 deletions
diff --git a/awesomplete.js b/awesomplete.js
index 41f94ee..a0eda9c 100644
--- a/awesomplete.js
+++ b/awesomplete.js
@@ -96,6 +96,7 @@ var _ = function (input, o) {
}
if (li && evt.button === 0) { // Only select on left click
+ evt.preventDefault();
me.select(li, evt);
}
}
diff --git a/test/events/mousedownSpec.js b/test/events/mousedownSpec.js
index 8b75b84..da5427e 100644
--- a/test/events/mousedownSpec.js
+++ b/test/events/mousedownSpec.js
@@ -10,7 +10,6 @@ describe("mousedown event", function () {
this.subject.input.focus();
this.subject.open();
$.type(this.subject.input, "ite");
- this.subject.next();
spyOn(this.subject, "select");
});
@@ -33,6 +32,7 @@ describe("mousedown event", function () {
it("selects item", function () {
var event = $.fire(this.target, "mousedown", { button: 0 });
expect(this.subject.select).toHaveBeenCalledWith(this.li, event);
+ expect(event.defaultPrevented).toBe(true);
});
});
@@ -50,6 +50,7 @@ describe("mousedown event", function () {
it("selects item", function () {
var event = $.fire(this.target, "mousedown", { button: 0 });
expect(this.subject.select).toHaveBeenCalledWith(this.li, event);
+ expect(event.defaultPrevented).toBe(true);
});
});
});