Revert "Ensure "focus" event is triggered when autofocusing"

This is not the right behavior and triggered "focus" when the browser naturally wouldn't (window not focused, element hidden).

This reverts commit b4745a816d.
This commit is contained in:
Javan Makhmali
2016-06-17 12:28:49 -04:00
parent 65cdb0bb3a
commit c2e82c4f08
+6 -11
View File
@@ -10,6 +10,11 @@ Trix.registerElement "trix-editor", do ->
# Contenteditable support helpers
autofocus = (element) ->
unless document.querySelector(":focus")
if element.hasAttribute("autofocus") and document.querySelector("[autofocus]") is element
element.focus()
makeEditable = (element) ->
return if element.hasAttribute("contenteditable")
element.setAttribute("contenteditable", "")
@@ -137,23 +142,13 @@ Trix.registerElement "trix-editor", do ->
@editorController ?= new Trix.EditorController(editorElement: this, html: @defaultValue = @value)
@editorController.registerSelectionManager()
@registerResetListener()
@autofocus()
autofocus(this)
requestAnimationFrame => @notify("initialize")
detachedCallback: ->
@editorController?.unregisterSelectionManager()
@unregisterResetListener()
# Autofocus support
autofocus: ->
unless document.querySelector(":focus")
if @hasAttribute("autofocus") and document.querySelector("[autofocus]") is this
focusTriggered = false
handleEventOnce("focus", onElement: this, withCallback: -> focusTriggered = true)
@focus()
triggerEvent("focus", onElement: this) unless focusTriggered
# Form reset support
registerResetListener: ->