From 2718e34b040551d2f91b63461fde726f4c570cf7 Mon Sep 17 00:00:00 2001 From: Koen Punt Date: Sat, 15 Oct 2016 15:10:04 +0200 Subject: [PATCH] only prevent default on touchevents when results are not showing fixes #2443 --- coffee/chosen.jquery.coffee | 6 +++--- coffee/chosen.proto.coffee | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/coffee/chosen.jquery.coffee b/coffee/chosen.jquery.coffee index fe76f2a4ee9..95f69cf820d 100644 --- a/coffee/chosen.jquery.coffee +++ b/coffee/chosen.jquery.coffee @@ -69,8 +69,8 @@ class Chosen extends AbstractChosen @form_field_jq.trigger("chosen:ready", {chosen: this}) register_observers: -> - @container.bind 'touchstart.chosen', (evt) => this.container_mousedown(evt); evt.preventDefault() - @container.bind 'touchend.chosen', (evt) => this.container_mouseup(evt); evt.preventDefault() + @container.bind 'touchstart.chosen', (evt) => this.container_mousedown(evt); return + @container.bind 'touchend.chosen', (evt) => this.container_mouseup(evt); return @container.bind 'mousedown.chosen', (evt) => this.container_mousedown(evt); return @container.bind 'mouseup.chosen', (evt) => this.container_mouseup(evt); return @@ -129,7 +129,7 @@ class Chosen extends AbstractChosen container_mousedown: (evt) -> return if @is_disabled - if evt and evt.type is "mousedown" and not @results_showing + if evt and evt.type in ['mousedown', 'touchstart'] and not @results_showing evt.preventDefault() if not (evt? and ($ evt.target).hasClass "search-choice-close") diff --git a/coffee/chosen.proto.coffee b/coffee/chosen.proto.coffee index 0e71614871e..5f9ed8c9dba 100644 --- a/coffee/chosen.proto.coffee +++ b/coffee/chosen.proto.coffee @@ -50,8 +50,8 @@ class @Chosen extends AbstractChosen @form_field.fire("chosen:ready", {chosen: this}) register_observers: -> - @container.observe "touchstart", (evt) => this.container_mousedown(evt); evt.preventDefault() - @container.observe "touchend", (evt) => this.container_mouseup(evt); evt.preventDefault() + @container.observe "touchstart", (evt) => this.container_mousedown(evt) + @container.observe "touchend", (evt) => this.container_mouseup(evt) @container.observe "mousedown", (evt) => this.container_mousedown(evt) @container.observe "mouseup", (evt) => this.container_mouseup(evt) @@ -124,7 +124,7 @@ class @Chosen extends AbstractChosen container_mousedown: (evt) -> return if @is_disabled - if evt and evt.type is "mousedown" and not @results_showing + if evt and evt.type in ['mousedown', 'touchstart'] and not @results_showing evt.stop() if not (evt? and evt.target.hasClassName "search-choice-close")