mirror of
https://github.com/atom/atom.git
synced 2026-02-19 02:44:29 -05:00
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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user