Skip to content

Commit

Permalink
Fix just released update input field and update to v0.0.24
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiden committed Oct 1, 2014
1 parent 6377c8b commit a40fa70
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
6 changes: 6 additions & 0 deletions angucomplete-alt.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,12 @@ angular.module('angucomplete-alt', [] ).directive('angucompleteAlt', ['$q', '$pa
updateInputField();
});
}
else if (scope.currentIndex === 0) {
scope.$apply(function() {
scope.currentIndex = -1;
inputField.val(scope.searchStr);
});
}
} else if (which === KEY_TAB && scope.results && scope.results.length > 0) {
if (scope.currentIndex === -1 && scope.showDropdown) {
scope.selectResult(scope.results[0]);
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angucomplete-alt",
"version": "0.0.23",
"version": "0.0.24",
"homepage": "http://ghiden.github.io/angucomplete-alt/",
"authors": [
"Hidenari Nozaki <[email protected]>"
Expand Down
2 changes: 1 addition & 1 deletion dist/angucomplete-alt.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions test/angucomplete-alt.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,40 @@ describe('angucomplete-alt', function() {
expect(inputField.val()).toEqual('Emma Watson');
});

it('should change back to original when it goes up to input field', function() {
var element = angular.element('<div angucomplete-alt id="ex1" placeholder="Search people" selected-object="selectedPerson" local-data="people" search-fields="firstName,middleName,surname" title-field="firstName,surname" minlength="1"/>');
$scope.selectedPerson = undefined;
$scope.people = [
{firstName: 'Emma', middleName: 'C.D.', surname: 'Watson'},
{firstName: 'Elvis', middleName: 'A.', surname: 'Presly'},
{firstName: 'John', middleName: 'A.', surname: 'Elway'}
];
$compile(element)($scope);
$scope.$digest();

var inputField = element.find('#ex1_value');
var eKeydown = $.Event('keydown');
var eKeyup = $.Event('keyup');

inputField.val('e');
inputField.trigger('input');
eKeyup.which = 101;// letter e
inputField.trigger(eKeyup);
$timeout.flush();

// Down arrow 2 times
eKeydown.which = KEY_DW;
inputField.trigger(eKeydown);
inputField.trigger(eKeydown);
expect(inputField.val()).toEqual('Elvis Presly');

// Up arrow 2 time and go back to original input
eKeydown.which = KEY_UP;
inputField.trigger(eKeydown);
inputField.trigger(eKeydown);
expect(inputField.val()).toEqual('e');
});

it('should reset input field when ESC key is pressed after up/down arrow key is pressed', function() {
var element = angular.element('<div angucomplete-alt id="ex1" placeholder="Search people" selected-object="selectedPerson" local-data="people" search-fields="firstName,middleName,surname" title-field="firstName,surname" minlength="1"/>');
$scope.selectedPerson = undefined;
Expand Down

0 comments on commit a40fa70

Please sign in to comment.