Modal panel focusout


#1

More time gone since run-in-terminal was made and I did not check all functionality on newer and newer atom versions, but it looks like something is broken now.
I have modal window for text input:

class ArgumentsRequester
    constructor: (label_text) ->
        @root = document.createElement("div")
        @root.classList.add("run-in-terminal-input-with-label")
        @message = document.createElement("div")
        @message.textContent = label_text
        @message.classList.add("message")
        @root.appendChild(@message)
        @line_edit_model = atom.workspace.buildTextEditor(mini: true)
        @line_edit_view = atom.views.getView(@line_edit_model)
        @root.appendChild(@line_edit_view)
        @panel = atom.workspace.addModalPanel({
            item: @root,
            visible: false,
        })
        @line_edit_view.addEventListener("focusout", @save_and_hide)
        @line_edit_view.addEventListener("keydown", @key_pressed)
        @attributes_memory = {}
    destroy: ->
        @panel.destroy()
        @root.remove()
    show: (@path) ->
        console.log("show")
        if not @panel.isVisible()
            @line_edit_model.setText(@attributes_memory[@path] or "")
            @panel.show()
            @line_edit_view.focus()
            @line_edit_model.selectAll()
    save_and_hide: =>
        console.log("save and hide")
        @attributes_memory[@path] = @line_edit_model.getText()
        @panel.hide()
    key_pressed: (e) =>
        console.log("key pressed")
        switch e.keyCode
            when 27
                @save_and_hide()
            when 13
                @save_and_hide()
                start_terminal(@path or "", @line_edit_model.getText())

In console I got:

show
save and hide

So, the focusout event triggers and I don’t know why. And it does not matter start sequence from context menu or by shortcut.
If I comment @line_edit_view.focus(), then there is no “focusout” event, but line edit have no focus as expected.