Skip to content

Commit

Permalink
After resetting search, move focus back to the search field.
Browse files Browse the repository at this point in the history
  • Loading branch information
eheikes committed Jul 4, 2015
1 parent fa3eae2 commit b17dac9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion toread.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ module.directive('list', function($timeout, toreadService) {
});
};

scope.clearSearch = function() {
scope.clearSearch = function(event) {
scope.q = '';
scope.showList();
angular.element(event.target).parents('.search').find('input[name="q"]').focus();
};

scope.$on('refreshList', scope.showList);
Expand Down
4 changes: 2 additions & 2 deletions toreadcontrols.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
</div>
<div class="col-md-6">
<div class="search input-group has-feedback">
<input class="form-control" ng-class="{'alert-info': q != ''}" type="text" value="" placeholder="Search" ng-model="q" ng-change="showList()" ng-disabled="actionInProgress">
<input class="form-control" ng-class="{'alert-info': q != ''}" name="q" type="text" value="" placeholder="Search" ng-model="q" ng-change="showList()" ng-disabled="actionInProgress">
<span class="glyphicon glyphicon-search form-control-feedback" ng-class="{hidden: q != ''}" aria-hidden="true"></span>
<span class="input-group-btn">
<button class="btn btn-default" ng-class="{hidden: q == ''}" type="button" aria-label="Clear search" ng-click="clearSearch()">
<button class="btn btn-default" ng-class="{hidden: q == ''}" type="button" aria-label="Clear search" ng-click="clearSearch($event)">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
</button>
</span>
Expand Down

0 comments on commit b17dac9

Please sign in to comment.