Handle focus at the host element level

Detecting focus and blur at the level of the input is creating problems
when we blur and then immediately refocus. This is simpler.
This commit is contained in:
Nathan Sobo
2014-10-16 19:55:42 -06:00
parent 62c0db11ee
commit eb19989ecd
3 changed files with 9 additions and 20 deletions

View File

@@ -107,8 +107,6 @@ TextEditorComponent = React.createClass
ref: 'input'
className: 'hidden-input'
style: hiddenInputStyle
onFocus: @onInputFocused
onBlur: @onInputBlurred
LinesComponent {
ref: 'lines',
@@ -378,7 +376,6 @@ TextEditorComponent = React.createClass
listenForDOMEvents: ->
node = @getDOMNode()
node.addEventListener 'mousewheel', @onMouseWheel
node.addEventListener 'focus', @onFocus # For some reason, React's built in focus events seem to bubble
node.addEventListener 'textInput', @onTextInput
@refs.scrollView.getDOMNode().addEventListener 'mousedown', @onMouseDown
@@ -432,8 +429,13 @@ TextEditorComponent = React.createClass
subscriptions.add atom.config.observe scopeDescriptor, 'editor.showLineNumbers', @setShowLineNumbers
subscriptions.add atom.config.observe scopeDescriptor, 'editor.scrollSensitivity', @setScrollSensitivity
onFocus: ->
@refs.input.focus() if @isMounted()
focused: ->
if @isMounted()
@setState(focused: true)
@refs.input.focus()
blurred: ->
@setState(focused: false)
onTextInput: (event) ->
event.stopPropagation()
@@ -456,12 +458,6 @@ TextEditorComponent = React.createClass
inputNode.value = event.data if editor.insertText(event.data)
onInputFocused: ->
@setState(focused: true)
onInputBlurred: ->
@setState(focused: false)
onVerticalScroll: (scrollTop) ->
{editor} = @props