Don't auto-scroll when clicking checkbox in doc picker

Rel #609.
pull/385/merge
Thibaut Courouble 8 years ago
parent a8073b3a12
commit 655beec28c

@ -3,6 +3,7 @@ class app.views.DocPicker extends app.View
@events: @events:
mousedown: 'onMouseDown' mousedown: 'onMouseDown'
mouseup: 'onMouseUp'
init: -> init: ->
@addSubview @listFold = new app.views.ListFold(@el) @addSubview @listFold = new app.views.ListFold(@el)
@ -64,13 +65,18 @@ class app.views.DocPicker extends app.View
@mouseDown = Date.now() @mouseDown = Date.now()
return return
onMouseUp: =>
@mouseUp = Date.now()
return
onDOMFocus: (event) => onDOMFocus: (event) =>
target = event.target target = event.target
if target.tagName is 'INPUT' if target.tagName is 'INPUT'
$.scrollTo target.parentNode, null, 'continuous' unless (@mouseDown and Date.now() < @mouseDown + 100) or (@mouseUp and Date.now() < @mouseUp + 100)
$.scrollTo target.parentNode, null, 'continuous'
else if target.classList.contains(app.views.ListFold.targetClass) else if target.classList.contains(app.views.ListFold.targetClass)
target.blur() target.blur()
unless @mouseDown and @mouseDown > Date.now() - 100 unless @mouseDown and Date.now() < @mouseDown + 100
if @focusEl is $('input', target.nextElementSibling) if @focusEl is $('input', target.nextElementSibling)
@listFold.close(target) if target.classList.contains(app.views.ListFold.activeClass) @listFold.close(target) if target.classList.contains(app.views.ListFold.activeClass)
prev = target.previousElementSibling prev = target.previousElementSibling

Loading…
Cancel
Save