mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-15 04:00:34 +08:00
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:
commit
49829872c6
@ -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,
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user