From 54394236e589be03c39b76fdfea861ba171193f1 Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Thu, 31 Dec 2009 02:40:10 -0500 Subject: Fix a regression where buttons were not clickable via link-hints --- linkHints.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/linkHints.js b/linkHints.js index 9831f3fe..047cbcae 100644 --- a/linkHints.js +++ b/linkHints.js @@ -161,8 +161,9 @@ function updateLinkHints() { deactivateLinkHintsMode(); else if (linksMatched.length == 1) { var matchedLink = linksMatched[0]; - if (isInputOrText(matchedLink)) { + if (isSelectable(matchedLink)) { matchedLink.focus(); + // When focusing a textbox, put the selection caret at the end of the textbox's contents. matchedLink.setSelectionRange(matchedLink.value.length, matchedLink.value.length); } else { // When we're opening the link in the current tab, don't navigate to the selected link immediately; @@ -177,6 +178,15 @@ function updateLinkHints() { } } +/* + * Selectable means the element has a text caret; this is not the same as "focusable". + */ +function isSelectable(element) { + var selectableTypes = ["search", "text", "password"]; + return (element.tagName == "INPUT" && selectableTypes.indexOf(element.type) >= 0) || + element.tagName == "TEXTAREA"; +} + /* * Hides link hints which do not match the given search string. To allow the backspace key to work, this * will also show link hints which do match but were previously hidden. -- cgit v1.2.3