From b28980916f21ccb6656d54e272f3b93910c4f466 Mon Sep 17 00:00:00 2001 From: Benjamin Reed Date: Thu, 12 May 2016 12:10:07 -0400 Subject: [PATCH] fix(nodes): scroll to top when the search is modified in the node list --- src/app/nodes/NodesController.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/nodes/NodesController.js b/src/app/nodes/NodesController.js index 68f0fee..62d1b11 100644 --- a/src/app/nodes/NodesController.js +++ b/src/app/nodes/NodesController.js @@ -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; @@ -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; @@ -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(); });