From 2910e017bbb940764e2cd2f29d3f8dae5ab30acb Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 27 Oct 2014 14:24:13 -0600 Subject: [PATCH] Unmount TextEditorComponent when TextEditor is destroyed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don’t want to do it when the element is detached because it might be caused by moving the editor rather than destroying it. Unmounting the component entirely and then remounting it causes the hidden input to not be recycled, interfering with focus restoration. Watching for destruction of the model is a good way to ensure we always tear down the view at the right time without doing it prematurely. --- src/text-editor-element.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/text-editor-element.coffee b/src/text-editor-element.coffee index 3313e3718..2e65a85c2 100644 --- a/src/text-editor-element.coffee +++ b/src/text-editor-element.coffee @@ -43,6 +43,7 @@ class TextEditorElement extends HTMLElement @mountComponent() @addGrammarScopeAttribute() @model.onDidChangeGrammar => @addGrammarScopeAttribute() + @model.onDidDestroy => @unmountComponent() @__spacePenView.setModel(@model) @model