Skip to content

Commit

Permalink
fix(uiView): Do NOT autoscroll when autoscroll attr is missing
Browse files Browse the repository at this point in the history
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
  • Loading branch information
timkindberg committed Mar 6, 2014
1 parent cb1c9cf commit 126e2a5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/viewDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ function $ViewDirective( $state, $compile, $controller, $injector, $ui
currentScope.$emit('$viewContentLoaded');
if (onloadExp) currentScope.$eval(onloadExp);

if (!angular.isDefined(autoscrollExp) || !autoscrollExp || $scope.$eval(autoscrollExp)) {
if (angular.isDefined(autoscrollExp) && !autoscrollExp || $scope.$eval(autoscrollExp)) {
$uiViewScroll(currentEl);
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/viewDirectiveSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,12 @@ describe('uiView', function () {
});

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

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

0 comments on commit 126e2a5

Please sign in to comment.