Skip to content

Commit 126e2a5

Browse files
committed
fix(uiView): Do NOT autoscroll when autoscroll attr is missing
Breaking Change: If you had ui-views that you wanted to autoscroll to on state change, you may now need to explicitly add `autoscroll="true"`. Fixes #807
1 parent cb1c9cf commit 126e2a5

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/viewDirective.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ function $ViewDirective( $state, $compile, $controller, $injector, $ui
278278
currentScope.$emit('$viewContentLoaded');
279279
if (onloadExp) currentScope.$eval(onloadExp);
280280

281-
if (!angular.isDefined(autoscrollExp) || !autoscrollExp || $scope.$eval(autoscrollExp)) {
281+
if (angular.isDefined(autoscrollExp) && !autoscrollExp || $scope.$eval(autoscrollExp)) {
282282
$uiViewScroll(currentEl);
283283
}
284284
}

test/viewDirectiveSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,12 @@ describe('uiView', function () {
278278
});
279279

280280
describe('autoscroll attribute', function () {
281-
it('should autoscroll when unspecified', inject(function ($state, $q, $uiViewScroll, $animate) {
281+
it('should NOT autoscroll when unspecified', inject(function ($state, $q, $uiViewScroll, $animate) {
282282
elem.append($compile('<div><ui-view></ui-view></div>')(scope));
283283
$state.transitionTo(aState);
284284
$q.flush();
285285
if ($animate) $animate.flush();
286-
expect($uiViewScroll).toHaveBeenCalledWith(elem.find('span').parent());
286+
expect($uiViewScroll).not.toHaveBeenCalledWith(elem.find('span').parent());
287287
}));
288288

289289
it('should autoscroll when expression is missing', inject(function ($state, $q, $uiViewScroll, $animate) {

0 commit comments

Comments
 (0)