Skip to content

Commit

Permalink
fix(nodes): scroll to top when the search is modified in the node list
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Reed committed May 12, 2016
1 parent 4563b75 commit b289809
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/app/nodes/NodesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
controller: 'NodesCtrl'
});
})
.controller('NodesCtrl', function($ionicLoading, $log, $q, $scope, $state, $timeout, $window, Cache, Capabilities, debounce, Errors, NodeService, storage, util) {
.controller('NodesCtrl', function($ionicLoading, $ionicScrollDelegate, $log, $q, $scope, $state, $timeout, $window, Cache, Capabilities, debounce, Errors, NodeService, storage, util) {
$log.info('NodesCtrl: initializing.');

$scope.searching = false;
Expand Down Expand Up @@ -92,6 +92,9 @@
if (nodes.length === MAX_NODE_LIST_LENGTH && (angular.isUndefined(searchFor) || searchFor.trim() === '')) {
$scope.nodes.push({id:'more'});
}
if ($scope.searchString !== $scope.lastSearchString) {
$ionicScrollDelegate.$getByHandle('nodes-scroll').scrollTop(false);
}
}, function(err) {
Errors.set('nodes', err);
$scope.error = true;
Expand Down Expand Up @@ -120,7 +123,10 @@
$scope.nodes = [];
}

$scope.$watch('searchString', function(newValue) {
$scope.$watch('searchString', function(newValue, oldValue) {
if (newValue !== oldValue) {
$scope.lastSearchString = oldValue;
}
storage.set('opennms.nodes.search-string', newValue);
$scope.delayedSearch();
});
Expand Down

0 comments on commit b289809

Please sign in to comment.