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, });