mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Handle TextEditorElement::focus() while parent is being attached
Fixes atom/autocomplete#61
This commit is contained in:
@@ -98,6 +98,22 @@ describe "TextEditorElement", ->
|
||||
document.body.focus()
|
||||
expect(blurCalled).toBe true
|
||||
|
||||
describe "when focused while a parent node is being attached to the DOM", ->
|
||||
class ElementThatFocusesChild extends HTMLDivElement
|
||||
attachedCallback: ->
|
||||
@firstChild.focus()
|
||||
|
||||
document.registerElement("element-that-focuses-child",
|
||||
prototype: ElementThatFocusesChild.prototype
|
||||
)
|
||||
|
||||
it "proxies the focus event to the hidden input", ->
|
||||
element = new TextEditorElement
|
||||
parentElement = document.createElement("element-that-focuses-child")
|
||||
parentElement.appendChild(element)
|
||||
jasmineContent.appendChild(parentElement)
|
||||
expect(element.shadowRoot.activeElement).toBe element.shadowRoot.querySelector('input')
|
||||
|
||||
describe "when the themes finish loading", ->
|
||||
[themeReloadCallback, initialThemeLoadComplete, element] = []
|
||||
|
||||
|
||||
@@ -63,7 +63,8 @@ class TextEditorElement extends HTMLElement
|
||||
@buildModel() unless @getModel()?
|
||||
@mountComponent() unless @component?.isMounted()
|
||||
@component.checkForVisibilityChange()
|
||||
@focus() if @focusOnAttach
|
||||
if this is document.activeElement
|
||||
@focused()
|
||||
@emitter.emit("did-attach")
|
||||
|
||||
detachedCallback: ->
|
||||
@@ -128,10 +129,7 @@ class TextEditorElement extends HTMLElement
|
||||
@component = null
|
||||
|
||||
focused: ->
|
||||
if @component?
|
||||
@component.focused()
|
||||
else
|
||||
@focusOnAttach = true
|
||||
@component?.focused()
|
||||
|
||||
blurred: (event) ->
|
||||
unless @useShadowDOM
|
||||
|
||||
Reference in New Issue
Block a user