-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Collapse does not expand if div is hidden #1774
Comments
This is default behavior because ngShow uses |
@craftyInstigator I think @Gamemaniak is totally right here. You would have to provide the exact reproduce scenario using http://plnkr.co/ to confirm. |
display setting and ng-show has absolutely nothing to do with this problem. This is caused by the animation failing to complete and never triggering .then callback to finalize the expand. As a result the class is never switched to "collapse in" and is stuck at "collapsing" and the height remains explicitly set to 0 on the element. The bug is in collapse.js:
when hidden, element[0].scrollHeight evaluates to 0, expandDone callback passed to .then is not invoked. I was able to fix the problem with the following code change:
This way I avoid the animation while the scrollHeight is 0 (hidden) I also to make sure update the collapse class to do a similar thing:
|
http://plnkr.co/edit/rVAfic6bdk9FHJpodyqm?p=preview
|
Thanks for the test case, @craftyInstigator . This is a limitation of the $transition service. This issue should be resolved by #1444 when it lands. |
FYI, I ran into the same problem as originally described. Turns out to have been caused by a race condition in the code. Setting a |
@bvaughn - thanks for the tip. Could you be more specific tho? Trying to work around this but not sure where to set this transition time - |
@juniorplenty Yeah if I recalled it seemed like a race condition where the component isn't expecting a transition to complete synchronously. Should be able to work around it by adding the following: .collapsing{
position: relative;
height: 0;
overflow: hidden;
-webkit-transition: height .35s ease;
transition: height .35s ease;
} |
What's the status on this? I've updated the plnkr to Angular 1.3 and boostrap-ui to 0.11.2, but issue still occurs: |
I'm also still having the same issue with all the latest versions. As @craftyInstigator pointed out, this issue's caused when the value of the elements You can see it in action in this simple example. If you try to set the height of the block to it's existing height, then http://plnkr.co/edit/E8OBPOm2RAcsINaTxDzJ?p=preview So are there 2 issues here?
Here's an example of a simplistic solution for 2) http://plnkr.co/edit/dH51D09dOWIEoOICsGJR?p=preview I say simplistic, as there are potential issues depending on the usage of $transition by all components within bootstrap ui. The value passed in must match the existing value exactly - so obviously 0 won't match 0px. So in the
would need to be changed to this
My idea for the solution came from the SO post below, in which the answer suggests setting the element css to it's new value and then comparing it to the original. This should help this issue, but i was unable to get it to work, as even though the new value has been set on the element, the old value is still returned. |
I'm interested in this too (I've encountered the problem as well). For angular purposes, the easy solution is to use Maybe if it's hidden then resolve immediately? |
- Animations are now opt-in, include ngAnimate to see collapse animations - ngAnimate handles initial state and doesn't animate if first reflow hasn't occurred. angular/angular.js@cc58460 - Tests may need more work. Right now they test for 'in' class. Fixes angular-ui#1774 Fixes angular-ui#2821 Fixes angular-ui#2836 Closes angular-ui#1274 Closes angular-ui#1444
- Animations are now opt-in, include ngAnimate to see collapse animations - ngAnimate handles initial state and doesn't animate if first reflow hasn't occurred. angular/angular.js@cc58460 - Tests may need more work. Right now they test for 'in' class. Fixes angular-ui#1774 Fixes angular-ui#2821 Fixes angular-ui#2836 Closes angular-ui#1274 Closes angular-ui#1444
- Animations are now opt-in, include ngAnimate to see collapse animations - ngAnimate handles initial state and doesn't animate if first reflow hasn't occurred. angular/angular.js@cc58460 - Tests may need more work. Right now they test for 'in' class. Fixes angular-ui#1774 Fixes angular-ui#2821 Fixes angular-ui#2836 Closes angular-ui#1274 Closes angular-ui#1444
Can this fix to be applied to 0.12? We who are still with Angular 1.2.X need this fix as well. |
If a div is hidden when collapse value is toggled from true to false, the div is not expanded, and is stuck in collapsed state with a class 'collapsing'. This can be easily reproduced by setting collapse to true, setting ng-show to false, then set collapse value to false, then set ng-show to true. The div will remain collapsed even though collapse value is now false.
The text was updated successfully, but these errors were encountered: