Skip to content

fix(uiView): Do NOT autoscroll when autoscroll attr is missing #932

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 7, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 || scope.$eval(autoScrollExp)) {
$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