Skip to content

Commit

Permalink
Allow focus of buttons to enter insert mode to fix youtube issue
Browse files Browse the repository at this point in the history
This fixes issue philc#1882. Justification given in the added comment.
  • Loading branch information
mrmr1993 committed Feb 26, 2016
1 parent a3cf3d1 commit 3ea5117
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/dom_utils.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,12 @@ DomUtils =
# enter insert mode if focused. Also note that the "contentEditable" attribute can be set on any element
# which makes it a rich text editor, like the notes on jjot.com.
isEditable: (element) ->
(@isSelectable element) or element.nodeName?.toLowerCase() == "select"
# Including <button> is a hack to make youtube playlist input not conflict with us (issue #1882).
# NOTE(mrmr1993): We never focus a <button> ourselves, so this can only occur when the user focuses a
# button with tab/the mouse or a script focuses it (as youtube does).
# It should be rare that this will happen and a user will immediately want to use Vimium, so requiring
# them to exit insert mode with <esc> before proceding will break very few workflows. I hope.
(@isSelectable element) or element.nodeName?.toLowerCase() in ["select", "button"]

# Embedded elements like Flash and quicktime players can obtain focus.
isEmbed: (element) ->
Expand Down

0 comments on commit 3ea5117

Please sign in to comment.