From 0e7349c00a6fa278945240d15d3593b03fdf3101 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Wed, 4 Nov 2015 17:27:51 +0100 Subject: [PATCH] Make it possible to blur scrollable elements Scrollable elements _are_ focusable (both by using `` and by using VimFx's `f` commands), but they aren't marked as such by the browser. In order to interfere as little as possible, VimFx only blurs elements marked as focusable. This made it impossible to blur scrollable elements, preventing you from scrolling the entire page again. This commits now also allows scrollable elements to blurred as a special-case. --- extension/lib/commands-frame.coffee | 8 ++++---- extension/lib/utils.coffee | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/extension/lib/commands-frame.coffee b/extension/lib/commands-frame.coffee index 376ab68..09461dc 100644 --- a/extension/lib/commands-frame.coffee +++ b/extension/lib/commands-frame.coffee @@ -291,16 +291,16 @@ commands.move_focus = ({ vim, storage, direction }) -> utils.moveFocus(direction) -commands.esc = ({ vim }) -> - utils.blurActiveElement(vim.content) +commands.esc = (args) -> + commands.blur_active_element(args) - { document } = vim.content + { document } = args.vim.content if document.exitFullscreen document.exitFullscreen() else document.mozCancelFullScreen() commands.blur_active_element = ({ vim }) -> - utils.blurActiveElement(vim.content) + utils.blurActiveElement(vim.content, vim.state.scrollableElements) module.exports = commands diff --git a/extension/lib/utils.coffee b/extension/lib/utils.coffee index f776afe..a69f6cf 100644 --- a/extension/lib/utils.coffee +++ b/extension/lib/utils.coffee @@ -96,11 +96,12 @@ getActiveElement = (window) -> else return activeElement -blurActiveElement = (window) -> +blurActiveElement = (window, extraAllowedElements = null) -> # Only blur focusable elements, in order to interfere with the browser as # little as possible. activeElement = getActiveElement(window) - if activeElement and activeElement.tabIndex > -1 + if activeElement and + (activeElement.tabIndex > -1 or extraAllowedElements?.has(activeElement)) activeElement.blur() blurActiveBrowserElement = (vim) -> -- 2.39.3