Unmount TextEditorComponent when TextEditor is destroyed

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.
This commit is contained in:
Nathan Sobo
2014-10-27 14:24:13 -06:00
parent 248e164de2
commit 2910e017bb

View File

@@ -43,6 +43,7 @@ class TextEditorElement extends HTMLElement
@mountComponent()
@addGrammarScopeAttribute()
@model.onDidChangeGrammar => @addGrammarScopeAttribute()
@model.onDidDestroy => @unmountComponent()
@__spacePenView.setModel(@model)
@model