mirror of
https://github.com/basecamp/trix.git
synced 2026-06-16 12:04:34 +00:00
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:
@@ -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: ->
|
||||
|
||||
Reference in New Issue
Block a user