Skip to content

Commit affe5bd

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 4d74d98 commit affe5bd

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/viewDirective.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,6 @@
100100
* Examples for `autoscroll`:
101101
*
102102
* <pre>
103-
* <!-- If autoscroll unspecified, then scroll ui-view into view
104-
* (Note: this default behavior is under review and may be reversed) -->
105-
* <ui-view/>
106-
*
107103
* <!-- If autoscroll present with no expression,
108104
* then scroll ui-view into view -->
109105
* <ui-view autoscroll/>
@@ -214,7 +210,7 @@ function $ViewDirective( $state, $injector, $uiViewScroll) {
214210

215211
var clone = $transclude(newScope, function(clone) {
216212
renderer.enter(clone, $element, function onUiViewEnter() {
217-
if (!angular.isDefined(autoScrollExp) || !autoScrollExp || scope.$eval(autoScrollExp)) {
213+
if (angular.isDefined(autoScrollExp) && !autoScrollExp || scope.$eval(autoScrollExp)) {
218214
$uiViewScroll(clone);
219215
}
220216
});

test/viewDirectiveSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,15 @@ describe('uiView', function () {
268268
});
269269

270270
describe('autoscroll attribute', function () {
271-
it('should autoscroll when unspecified', inject(function ($state, $q, $uiViewScroll, $animate) {
271+
it('should NOT autoscroll when unspecified', inject(function ($state, $q, $uiViewScroll, $animate) {
272272
elem.append($compile('<div><ui-view></ui-view></div>')(scope));
273273

274274
$state.transitionTo(aState);
275275
$q.flush();
276276

277277
if ($animate) $animate.triggerCallbacks();
278278

279-
expect($uiViewScroll).toHaveBeenCalledWith(elem.find('span').parent());
279+
expect($uiViewScroll).not.toHaveBeenCalled();
280280
}));
281281

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

0 commit comments

Comments
 (0)