Skip to content

Commit

Permalink
directove shoud capture focus when loading a search page
Browse files Browse the repository at this point in the history
  • Loading branch information
nverba committed May 14, 2015
1 parent 4cee496 commit 832a0fa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion directives/tag/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ function TagSearchControllerFn($scope, $location, $http, $router) {
// cache previous_page url when leaving non search page
if ($location.path() !== '/search') {
previous_page = $location.url();
} else {
this.captureFocus();
}
var updated_params = $location.search()["tags[]"];
this.string = updated_params ? parseParams(updated_params) : '';
Expand All @@ -84,9 +86,13 @@ function tagSearchFn ($location, $http, $timeout) {
templateUrl: 'directives/tag/tag.html',
link: function(scope, element, attrs) {

scope.tag.captureFocus = function () {
element[0].querySelector('#search-input').focus();
};

scope.tag.selectTag = function (tag) {
scope.tag.string = scope.tag.string.replace(/\S+$/, tag);
element[0].querySelector('#search-input').focus();
scope.tag.captureFocus();
};
}
};
Expand Down

0 comments on commit 832a0fa

Please sign in to comment.