Re-render component when EditorView is reattached

Fixes #3640
This commit is contained in:
Nathan Sobo
2014-09-26 15:13:07 -06:00
parent 1f2fc4bf00
commit b5fc4aec84
2 changed files with 8 additions and 1 deletions

View File

@@ -2259,6 +2259,11 @@ describe "TextEditorComponent", ->
editor.setGrammar(atom.syntax.nullGrammar)
expect(wrapperNode.dataset.grammar).toBe 'text plain null-grammar'
describe "detaching and reattaching the editor (regression)", ->
it "does not throw an exception", ->
wrapperView.detach()
wrapperView.attachToDom()
buildMouseEvent = (type, properties...) ->
properties = extend({bubbles: true, cancelable: true}, properties...)
properties.detail ?= 1

View File

@@ -95,7 +95,8 @@ class TextEditorView extends View
placeholderText: placeholderText
props = defaults({@editor, parentView: this}, props)
@component = React.renderComponent(TextEditorComponent(props), @element)
@componentDescriptor = TextEditorComponent(props)
@component = React.renderComponent(@componentDescriptor, @element)
node = @component.getDOMNode()
@@ -146,6 +147,7 @@ class TextEditorView extends View
return unless onDom
return if @attached
@attached = true
@component = React.renderComponent(@componentDescriptor, @element) unless @component.isMounted()
@component.checkForVisibilityChange()
@focus() if @focusOnAttach