I found out it really was because Poltergeist triggers the blur
in fill_in
. All I had to do was, before filling the typeahead field, execute this script:
page.execute_script "$('input[typeahead]').unbind('blur')"
This way, UI Typeahead's blur
event doesn't get called and it thinks it has the focus on the field, rendering the suggestions box accordingly.
In case you are not using JQuery, this script works with AngularJS:
elements = document.getElementsByTagName('input');
for (var i = 0; i < elements.length; i++) {
if (elements[i].hasAttribute('typeahead')) {
angular.element(elements[i]).unbind('blur');
}
}