Improve tab/focus navigation of doc picker

pull/417/merge
Thibaut Courouble 9 years ago
parent aa6b928324
commit a02dd3b7b4

@ -30,6 +30,7 @@ class app.views.DocPicker extends app.View
@empty()
app.appCache?.off 'progress', @onAppCacheProgress
$.off @el, 'focus', @onDOMFocus, true
@focusEl = null
return
render: ->
@ -101,8 +102,16 @@ class app.views.DocPicker extends app.View
else if target.classList.contains(app.views.ListFold.targetClass)
target.blur()
unless @mouseDown and @mouseDown > Date.now() - 100
if @focusEl is $('input', target.nextElementSibling)
@listFold.close(target) if target.classList.contains(app.views.ListFold.activeClass)
prev = target.previousElementSibling
prev = prev.previousElementSibling until prev.tagName is 'LABEL' or prev.classList.contains(app.views.ListFold.targetClass)
prev = $.makeArray($$('input', prev.nextElementSibling)).pop() if prev.classList.contains(app.views.ListFold.activeClass)
@delay -> prev.focus()
else
@listFold.open(target) unless target.classList.contains(app.views.ListFold.activeClass)
$('input', target.nextElementSibling).focus()
@delay -> $('input', target.nextElementSibling).focus()
@focusEl = target
return
onEnter: =>

Loading…
Cancel
Save