Unified · Split
| @@ -30,6 +30,7 @@ class app.views.DocPicker extends app.View · 29 unmodified lines | ||
| 30 | 30 | @empty() |
| 31 | 31 | app.appCache?.off 'progress', @onAppCacheProgress |
| 32 | 32 | $.off @el, 'focus', @onDOMFocus, true |
| 33 | + @focusEl = null | |
| 33 | 34 | return |
| 34 | 35 | |
| 35 | 36 | render: -> |
| @@ -101,8 +102,16 @@ class app.views.DocPicker extends app.View · 65 unmodified lines | ||
| 101 | 102 | else if target.classList.contains(app.views.ListFold.targetClass) |
| 102 | 103 | target.blur() |
| 103 | 104 | unless @mouseDown and @mouseDown > Date.now() - 100 |
| 104 | − @listFold.open(target) unless target.classList.contains(app.views.ListFold.activeClass) | |
| 105 | − $('input', target.nextElementSibling).focus() | |
| 105 | + if @focusEl is $('input', target.nextElementSibling) | |
| 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 | 115 | return |
| 107 | 116 | |
| 108 | 117 | onEnter: => |