From 781e4ffd4fa292fe312b8ba18784bbf5d6911e78 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Sun, 20 Dec 2015 19:04:27 -0600 Subject: [PATCH] Added onResult function to type ahead --- notebook/static/notebook/js/commandpalette.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/notebook/static/notebook/js/commandpalette.js b/notebook/static/notebook/js/commandpalette.js index 357c149cd..76249331b 100644 --- a/notebook/static/notebook/js/commandpalette.js +++ b/notebook/static/notebook/js/commandpalette.js @@ -117,6 +117,15 @@ define(function(require){ mod.modal('hide'); }; + /* Whenever a result is rendered, if there is only one resulting + * element then automatically select that element. + */ + var onResult = function(node, query, result, resultCount) { + if (resultCount == 1) { + $('.typeahead-list > li:nth-child(2)').addClass('active'); + } + }; + // generate structure needed for typeahead layout and ability to search var src = {}; @@ -164,7 +173,8 @@ define(function(require){ source: src, callback: { onSubmit: onSubmit, - onClickAfter: onSubmit + onClickAfter: onSubmit, + onResult: onResult }, debug: false, });