diff --git a/internal_packages/composer/lib/composer-view.cjsx b/internal_packages/composer/lib/composer-view.cjsx index de55c0681..000037e5e 100644 --- a/internal_packages/composer/lib/composer-view.cjsx +++ b/internal_packages/composer/lib/composer-view.cjsx @@ -131,10 +131,10 @@ class ComposerView extends React.Component $el = React.findDOMNode(@refs[fieldName]) return if document.activeElement is $el or $el.contains(document.activeElement) - if @refs[fieldName].focus @refs[fieldName].focus() else + $el.select() $el.focus() componentWillReceiveProps: (newProps) => diff --git a/src/components/key-commands-region.cjsx b/src/components/key-commands-region.cjsx index 651912941..4f40cb897 100644 --- a/src/components/key-commands-region.cjsx +++ b/src/components/key-commands-region.cjsx @@ -100,12 +100,12 @@ class KeyCommandsRegion extends React.Component @state = {focused: false} @_goingout = false - @_in = (args...) => + @_in = (event) => @_goingout = false - @props.onFocusIn(args...) if @state.focused is false + @props.onFocusIn(event) if @state.focused is false @setState(focused: true) - @_out = => + @_out = (event) => @_goingout = true setTimeout => return unless @_goingout @@ -125,7 +125,9 @@ class KeyCommandsRegion extends React.Component # This prevents the strange effect of an input appearing to have focus # when the element receiving focus does not support selection (like a # 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 @setState(focused: false) @_goingout = false