Merge pull request #885 from captainsafia/autoselect-only-result

Autoselect command palette search result if there is only one result
Closes #678
This commit is contained in:
Carol Willing 2015-12-21 21:34:13 -08:00
commit 49829872c6

View File

@ -117,6 +117,17 @@ 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) {
requestAnimationFrame(function() {
$('.typeahead-list > li:nth-child(2)').addClass('active');
});
}
};
// generate structure needed for typeahead layout and ability to search
var src = {};
@ -164,7 +175,8 @@ define(function(require){
source: src,
callback: {
onSubmit: onSubmit,
onClickAfter: onSubmit
onClickAfter: onSubmit,
onResult: onResult
},
debug: false,
});