Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

TabsController handleWindowResize $apply #4743

@MarijnMensinga

Description

@MarijnMensinga

Hi,

While testing I detected that upon a window resize event the tabsController triggers an $digest already in progress error. This happens because here an $apply() is called.

Normally this does not occur, but since it is possible to have custom listeners that trigger on the same event an $digets might already be in progress.

So I suggest the $scope.$apply gets replaced by $scope.$applyAsync to fix this. Since the body of the function aleady implements this behaviour by calling $mdUtil.nextTick I think this is not a problem:

function handleWindowResize () {
  $scope.$apply(function () {
    ctrl.lastSelectedIndex = ctrl.selectedIndex;
    ctrl.offsetLeft        = fixOffset(ctrl.offsetLeft);
    $mdUtil.nextTick(ctrl.updateInkBarStyles, false);
    $mdUtil.nextTick(updatePagination);
  });
}

Source from here

Stacktrace:

Error: [$rootScope:inprog] $digest already in progress
http://errors.angularjs.org/1.4.5/$rootScope/inprog?p0=%24digest
minErr/<@project/library/Angular/1.4.5/angular.js:68:14
beginPhase@project/library/Angular/1.4.5/angular.js:16235:1
$RootScopeProvider/this.$get</Scope.prototype.$digest@project/library/Angular/1.4.5/angular.js:15669:13
$RootScopeProvider/this.$get</Scope.prototype.$apply@project/library/Angular/1.4.5/angular.js:15986:17
handleWindowResize@project/library/AngularMaterial/0.10.1/angular-material.js:16531:9
createEventHandler/eventHandler@project/library/Angular/1.4.5/angular.js:3293:11
createScrollableDirective/directive/<.link/<@project/angular-scrollable.js:126:15
$RootScopeProvider/this.$get</Scope.prototype.$digest@project/library/Angular/1.4.5/angular.js:15707:40
$RootScopeProvider/this.$get</Scope.prototype.$apply@project/library/Angular/1.4.5/angular.js:15986:17
tick@project/library/Angular/1.4.5/angular.js:11231:29

I'm looking forward to your response!
Marijn

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions