From b7d20cad6e854d03b1f10a6eb7c4e44cbb2437c3 Mon Sep 17 00:00:00 2001 From: Carl Helmertz Date: Sun, 26 Aug 2012 12:35:38 +0200 Subject: frontend: performFind was not focusing the next a-element To reproduce, pre-this-patch: 1 Enter find mode ('/') 2 Search for something that matches multiple a-hrefs on the page 3 'Enter' to indicate that you've found your search term 4 findNext ('n') 4a Now, the next element get's a highlight but is not focused 5 activate/goto ('enter') 5a The first found match (3) is triggered An easy way to reproduce: go to a gitweb page, search for "summary", try to go to any but the first link's href. Signed-off-by: Carl Helmertz --- content_scripts/vimium_frontend.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 5b7a7402..4e804d82 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -698,7 +698,8 @@ findAndFocus = (backwards) -> # if we have found an input element via 'n', pressing immediately afterwards sends us into insert # mode - elementCanTakeInput = DomUtils.isSelectable(document.activeElement) && + elementCanTakeInput = document.activeElement && + DomUtils.isSelectable(document.activeElement) && isDOMDescendant(findModeAnchorNode, document.activeElement) if (elementCanTakeInput) handlerStack.push({ -- cgit v1.2.3 From 71b1ad14af2f9ae3a05ac5e1712de3d57147a57b Mon Sep 17 00:00:00 2001 From: Carl Helmertz Date: Sun, 26 Aug 2012 12:43:55 +0200 Subject: frontend: Error when canceling ('esc') findMode document.activeElement does not get set prior to 1 Entering find mode; and 2 Canceling ('esc') before being satisfied with keyword ('enter') Signed-off-by: Carl Helmertz --- content_scripts/vimium_frontend.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 4e804d82..75092f79 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -660,7 +660,8 @@ selectFoundInputElement = -> # instead. however, since the last focused element might not be the one currently pointed to by find (e.g. # the current one might be disabled and therefore unable to receive focus), we use the approximate # heuristic of checking that the last anchor node is an ancestor of our element. - if (findModeQueryHasResults && DomUtils.isSelectable(document.activeElement) && + if (findModeQueryHasResults && document.activeElement && + DomUtils.isSelectable(document.activeElement) && isDOMDescendant(findModeAnchorNode, document.activeElement)) DomUtils.simulateSelect(document.activeElement) # the element has already received focus via find(), so invoke insert mode manually -- cgit v1.2.3