From d2421bb216413f1eb9422729a7c56d1125184f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 3 Sep 2014 07:41:43 +0200 Subject: [PATCH] Added better match when using graphite function autocomplete, hit tab key and the first match will be used, you no longer need to use the down arrow to select the typeahead match you want, just hit tab key --- src/app/directives/addGraphiteFunc.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/app/directives/addGraphiteFunc.js b/src/app/directives/addGraphiteFunc.js index 6898b838845..dc0a77a1ae0 100644 --- a/src/app/directives/addGraphiteFunc.js +++ b/src/app/directives/addGraphiteFunc.js @@ -38,6 +38,14 @@ function (angular, app, _, $, gfunc) { items: 10, updater: function (value) { var funcDef = gfunc.getFuncDef(value); + if (!funcDef) { + // try find close match + funcDef = _.find(allFunctions, function(funcName) { + return funcName.toLowerCase().indexOf(value) === 0; + }); + + if (!funcDef) { return; } + } $scope.$apply(function() { $scope.addFunction(funcDef);