History

Improve tab/focus navigation of doc picker

Thibaut Courouble committed 10 years ago

Commit a02dd3b1 parent aa6b9281 file · +11 −2Browse files

Unified · Split

assets/javascripts/views/sidebar/doc_picker.coffee+11−2
@@ -30,6 +30,7 @@ class app.views.DocPicker extends app.View · 29 unmodified lines
30 @empty()30 @empty()
31 app.appCache?.off 'progress', @onAppCacheProgress31 app.appCache?.off 'progress', @onAppCacheProgress
32 $.off @el, 'focus', @onDOMFocus, true32 $.off @el, 'focus', @onDOMFocus, true
33 @focusEl = null
33 return34 return
34 35
35 render: ->36 render: ->
@@ -101,8 +102,16 @@ class app.views.DocPicker extends app.View · 65 unmodified lines
101 else if target.classList.contains(app.views.ListFold.targetClass)102 else if target.classList.contains(app.views.ListFold.targetClass)
102 target.blur()103 target.blur()
103 unless @mouseDown and @mouseDown > Date.now() - 100104 unless @mouseDown and @mouseDown > Date.now() - 100
104 @listFold.open(target) unless target.classList.contains(app.views.ListFold.activeClass)105 if @focusEl is $('input', target.nextElementSibling)
105 $('input', target.nextElementSibling).focus()106 @listFold.close(target) if target.classList.contains(app.views.ListFold.activeClass)
107 prev = target.previousElementSibling
108 prev = prev.previousElementSibling until prev.tagName is 'LABEL' or prev.classList.contains(app.views.ListFold.targetClass)
109 prev = $.makeArray($$('input', prev.nextElementSibling)).pop() if prev.classList.contains(app.views.ListFold.activeClass)
110 @delay -> prev.focus()
111 else
112 @listFold.open(target) unless target.classList.contains(app.views.ListFold.activeClass)
113 @delay -> $('input', target.nextElementSibling).focus()
114 @focusEl = target
106 return115 return
107 116
108 onEnter: =>117 onEnter: =>