Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Issue in dropdown after angularjs update #3511

Closed
jainsneha23 opened this issue Apr 8, 2015 · 9 comments
Closed

Issue in dropdown after angularjs update #3511

jainsneha23 opened this issue Apr 8, 2015 · 9 comments

Comments

@jainsneha23
Copy link
Contributor

On upgrading angularjs to latest version, dropdown toggle function behaves wrong.
The on-toggle function of dropdown should be called after the dropdown is toggled. But the opposite happens.

Reason, is the animate function in dropdown controller.

  scope.$watch('isOpen', function( isOpen, wasOpen ) {
    $animate \[isOpen ? 'addClass' : 'removeClass'\](self.$element, openClass);
      if (angular.isDefined(isOpen) && isOpen !== wasOpen) {
          toggleInvoker($scope, {
              open: !!isOpen
          });
      }
  });

Here the toggleInvoker should be inside the resolve function of animate, as animate happens in the next digest cycle.

@jainsneha23
Copy link
Contributor Author

To test this issue, take the dropdown example code in the official website , update the angularjs, and in the toggle function, print the width of the dropdown container. As the function is called before the dropdown opens, it will print zero.

@karianna karianna added this to the 0.13.0 milestone Apr 8, 2015
@karianna
Copy link
Contributor

karianna commented Apr 8, 2015

Pretty sure this is fixed on Master

@jainsneha23
Copy link
Contributor Author

I guess not, i took the latest stable version just now. Also the official website says, angularjs bootstrap is tested in angularjs 1.2.x, and angularjs is updated to 1.3.15. So bootstrap angular also needs an update. It would be great.

@karianna
Copy link
Contributor

karianna commented Apr 8, 2015

@snehatulsi - by master I mean the HEAD of the master branch (the upcoming 0.13.0 release which will support angular 1.3)

@chrisirhc
Copy link
Contributor

Also, a Plunker to reproduce this would be very helpful for investigation.

@jainsneha23
Copy link
Contributor Author

A plunker for the same:
http://plnkr.co/edit/HPUEsVcSMu2Z7A2bDVBB?p=preview

The example is from the official site. In the newer angularjs version, open state has the width as 0, and closed state has the width to 2xx px.
Change the angularjs version to 2.1.x, then the opposite happens , which is the correct behavior.

@chrisirhc
Copy link
Contributor

I see, you're saying that the toggle doesn't run at the correct time. It should run after the animation rather than before the animation. That sounds reasonable.

Adding your PR, #3513, for reference here.

@jainsneha23
Copy link
Contributor Author

Yes thats the behavior in the previous versions. Also, after the dropdown is toggled in DOM, it should call the on-toggle function.
I tried to move toggleInvoker inside the resolve of the animation, but it moves angular $scope out of digest cycle. Is there any other solution, you could suggest, so that I can move out of this issue. I would be grateful. I also tried $$addClassImmediately, but there is no documentation on this. So, I am not in favour of using this function, available in latest angularjs versions only.

@karianna
Copy link
Contributor

@chrisirhc In the related PR you mentioned this should be fixed for the next release, but we've got the PR in the 0.13.x milestone....

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants