Skip to content

Commit

Permalink
only prevent default on touchevents when results are not showing (#2725)
Browse files Browse the repository at this point in the history
* only prevent default on touchevents when results are not showing

fixes #2443

* stop is not the same as preventDefault
  • Loading branch information
koenpunt committed Oct 27, 2016
1 parent 23a3ee6 commit bd47b88
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions coffee/chosen.jquery.coffee
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
8 changes: 4 additions & 4 deletions coffee/chosen.proto.coffee
Expand Up @@ -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)
Expand Down Expand Up @@ -124,8 +124,8 @@ class @Chosen extends AbstractChosen
container_mousedown: (evt) ->
return if @is_disabled

if evt and evt.type is "mousedown" and not @results_showing
evt.stop()
if evt and evt.type in ['mousedown', 'touchstart'] and not @results_showing
evt.preventDefault()

if not (evt? and evt.target.hasClassName "search-choice-close")
if not @active_field
Expand Down

0 comments on commit bd47b88

Please sign in to comment.