JustGoscha / allmighty-autocomplete

Simple to use autocomplete directive in a module for AngularJs!
MIT License
392 stars 232 forks source link

Not losing focus #109

Closed cskiwi closed 1 year ago

cskiwi commented 9 years ago

hi,

When I have this plugin in my app, whenever I press enter the on-select get's called whenever I have the focus on it or not. So maybe fix the enter checking on the document more to the inputfield?

document.addEventListener("keydown", function (e) {
    // other code
    case key.enter:
        if (scope.onSelect) {
            scope.onSelect(scope.searchParam);
        }
        break;
    }
}, true);

found out that putting

element[0].add..... fixes the problem, and still works beautiful :) I don't have git here availible so no fork request :/