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 7, 2014
1 parent 4d74d98 commit a25c89d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 1 addition & 5 deletions src/viewDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@
* Examples for `autoscroll`:
*
* <pre>
* <!-- If autoscroll unspecified, then scroll ui-view into view
* (Note: this default behavior is under review and may be reversed) -->
* <ui-view/>
*
* <!-- If autoscroll present with no expression,
* then scroll ui-view into view -->
* <ui-view autoscroll/>
Expand Down Expand Up @@ -214,7 +210,7 @@ function $ViewDirective( $state, $injector, $uiViewScroll) {

var clone = $transclude(newScope, function(clone) {
renderer.enter(clone, $element, function onUiViewEnter() {
if (!angular.isDefined(autoScrollExp) || !autoScrollExp || scope.$eval(autoScrollExp)) {
if (angular.isDefined(autoScrollExp) && !autoScrollExp || newScope.$eval(autoScrollExp)) {

This comment has been minimized.

Copy link
@timkindberg

timkindberg Mar 7, 2014

Author Contributor

@meenie is newScope the right scope var to use here?

This comment has been minimized.

Copy link
@meenie

meenie Mar 7, 2014

Contributor

No, it should probably be scope. But it's not an issue because scope.$new() doesn't create an isolate scope unless you pass in true. Might as well change it to scope though :). Good catch!

$uiViewScroll(clone);
}
});
Expand Down
4 changes: 2 additions & 2 deletions test/viewDirectiveSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,15 @@ 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.triggerCallbacks();

expect($uiViewScroll).toHaveBeenCalledWith(elem.find('span').parent());
expect($uiViewScroll).not.toHaveBeenCalled();
}));

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

0 comments on commit a25c89d

Please sign in to comment.