fix(composer): Fix tabbing from body to subject

This commit is contained in:
Ben Gotow 2016-01-11 18:13:42 -08:00
parent 963d86cfd3
commit 0360c59460
2 changed files with 7 additions and 5 deletions

View file

@ -131,10 +131,10 @@ class ComposerView extends React.Component
$el = React.findDOMNode(@refs[fieldName]) $el = React.findDOMNode(@refs[fieldName])
return if document.activeElement is $el or $el.contains(document.activeElement) return if document.activeElement is $el or $el.contains(document.activeElement)
if @refs[fieldName].focus if @refs[fieldName].focus
@refs[fieldName].focus() @refs[fieldName].focus()
else else
$el.select()
$el.focus() $el.focus()
componentWillReceiveProps: (newProps) => componentWillReceiveProps: (newProps) =>

View file

@ -100,12 +100,12 @@ class KeyCommandsRegion extends React.Component
@state = {focused: false} @state = {focused: false}
@_goingout = false @_goingout = false
@_in = (args...) => @_in = (event) =>
@_goingout = false @_goingout = false
@props.onFocusIn(args...) if @state.focused is false @props.onFocusIn(event) if @state.focused is false
@setState(focused: true) @setState(focused: true)
@_out = => @_out = (event) =>
@_goingout = true @_goingout = true
setTimeout => setTimeout =>
return unless @_goingout return unless @_goingout
@ -125,7 +125,9 @@ class KeyCommandsRegion extends React.Component
# This prevents the strange effect of an input appearing to have focus # This prevents the strange effect of an input appearing to have focus
# when the element receiving focus does not support selection (like a # when the element receiving focus does not support selection (like a
# div with tabIndex=-1) # div with tabIndex=-1)
document.getSelection().empty() if event.relatedTarget and event.relatedTarget.tagName isnt 'INPUT'
document.getSelection().empty()
@props.onFocusOut() if @state.focused is true @props.onFocusOut() if @state.focused is true
@setState(focused: false) @setState(focused: false)
@_goingout = false @_goingout = false