Skip to content

Commit 8bb9e27

Browse files
committed
fix(uiView): it should autoscroll when expr is missing.
1 parent 5fd1efc commit 8bb9e27

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/viewDirective.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* @restrict ECA
1212
*
1313
* @description
14-
* The ui-view directive tells $state where to place your templates.
14+
* The ui-view directive tells $state where to place your templates.
1515
* A view can be unnamed or named.
1616
*
1717
* @param {string} ui-view A view name.
@@ -123,7 +123,7 @@ function $ViewDirective( $state, $compile, $controller, $injector, $an
123123

124124
// TODO: This seems strange, shouldn't $anchorScroll listen for $viewContentLoaded if necessary?
125125
// $anchorScroll might listen on event...
126-
if (!angular.isDefined(attr.autoscroll) || scope.$eval(attr.autoscroll)) {
126+
if (!angular.isDefined(attr.autoscroll) || (!attr.autoscroll || scope.$eval(attr.autoscroll))) {
127127
$anchorScroll();
128128
}
129129
}

test/viewDirectiveSpec.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,20 @@ describe('uiView', function () {
216216
});
217217

218218
describe('autoscroll attribute', function () {
219-
it('should autoscroll when missing', inject(function ($state, $q, $anchorScroll) {
219+
it('should autoscroll when unspecified', inject(function ($state, $q, $anchorScroll) {
220220
elem.append($compile('<div ui-view></div>')(scope));
221221
$state.transitionTo(gState);
222222
$q.flush();
223223
expect($anchorScroll).toHaveBeenCalled();
224224
}));
225225

226+
it('should autoscroll when expr is missing', inject(function ($state, $q, $anchorScroll) {
227+
elem.append($compile('<div ui-view autoscroll></div>')(scope));
228+
$state.transitionTo(gState);
229+
$q.flush();
230+
expect($anchorScroll).toHaveBeenCalled();
231+
}));
232+
226233
it('should autoscroll when truthy', inject(function ($state, $q, $anchorScroll) {
227234
elem.append($compile('<div ui-view autoscroll="true"></div>')(scope));
228235
$state.transitionTo(gState);

0 commit comments

Comments
 (0)