diff --git a/spec/text-editor-component-spec.coffee b/spec/text-editor-component-spec.coffee index 807e5ab7b..cc76c4f6f 100644 --- a/spec/text-editor-component-spec.coffee +++ b/spec/text-editor-component-spec.coffee @@ -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 diff --git a/src/text-editor-view.coffee b/src/text-editor-view.coffee index 2e6663fcf..48ed5b4c1 100644 --- a/src/text-editor-view.coffee +++ b/src/text-editor-view.coffee @@ -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