From aa5653d111a45bf8eb8748221cf530e3b1c13c0f Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Thu, 19 Dec 2013 19:10:09 +0100 Subject: [PATCH] Keep active hint focused if it's still valid (#53). If a hint is focussed and later filter will keep it valid, the hint also keeps focussed. --- src/hints.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/hints.js b/src/hints.js index 0730c6b..590163e 100644 --- a/src/hints.js +++ b/src/hints.js @@ -231,7 +231,7 @@ var VbHint = (function(){ } function show() { - var i, hint, + var i, hint, newIdx, num = 1, matcher = getMatcher(filterText); @@ -261,7 +261,11 @@ var VbHint = (function(){ return fire(); } - return focusHint(0); + + /* if the previous active hint isn't valid set focus to first */ + if (!activeHint || validHints.indexOf(activeHint) < 0) { + return focusHint(0); + } } /* Returns a validator method to check if the hint elements text matches */ -- 2.20.1