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

ngMessages(ngAnimate 1.4.5?): Flash of content before animation begins. #12969

Open

Description

@topherfangio

I just noticed a bug which I thought was in Angular Material, but I now believe is in Angular itself.

When the animation for my ng-messages begins, there is a flash where you can see all messages before the animation begins. Although the issue is appearing with ngMessages, I think it might be a broader $animate issue because I can reproduce this by upgrading only angular.js and angular-animate.js from 1.4.4 to 1.4.5 (leaving everything else including angular-messages.js at 1.4.4).

Oddly, if I leave either file at 1.4.4 (it doesn't matter which one), the issue is not reproducible, so it seems to be an issue when both files are at version 1.4.5.

Version Introduced: 1.4.5?
Versions Tested: 1.4.4 (works here; broken on others), 1.4.5, 1.4.6, 1.5.0-beta.0
Browsers: All (IE Edge, Safari, Chrome/Firefox on both OS X and Windows)

Steps to Reproduce:

  1. Open https://codepen.io/topherfangio/pen/PPbLaR
  2. Click on the input and type a 5 so the new value is 12345

You will see the errors appear for a split second, disappear, and then they will animate into place.

Again, you can edit the Codepen settings to change either file to 1.4.4 and it fixes the issue.

Additional Info:

Might be related to #12825.

I did not see any relevant breaking changes in the changelog between 1.4.4 and 1.4.6 which would account for this. Please let me know if I can provide any additional information.

Activity

  1. ThomasBurleson commented on Sep 29, 2015

    @ThomasBurleson

    @robertmesserle - is this related to any changes you may have made ?
    @matsko - what are your thoughts here ?

  2. robertmesserle commented on Sep 29, 2015

    @robertmesserle

    @ThomasBurleson If this is an AngularJS issue, then no - I have no commits in the angular.js repo.

  3. matsko commented on Sep 29, 2015

    @matsko
    Contributor

    I see what's going on here. I'll have a look later today.

  4. added this to the 1.4.7 milestone on Sep 29, 2015
  5. topherfangio commented on Sep 29, 2015

    @topherfangio
    Author

    I reproduced the demo without material just to make sure it wasn't some weird interaction with our CSS/JS. You can view it below if it's helpful:

    https://codepen.io/topherfangio/pen/zvoXjz

    @matsko Thanks for taking a look!

  6. modified the milestones: 1.4.7, 1.4.8 on Oct 1, 2015
  7. kvetis commented on Oct 2, 2015

    @kvetis

    It also happens on ngIf in IE and Firefox, but not in Chrome. I've created a JSFiddle that illustrates the difference:

    Reproduction
    In this fiddle, delete the contents of the input box.
    http://jsfiddle.net/kvetis/ssnkqog6/3/
    Affected Versions: 1.4.5, 1.4.6, 1.4.7 (1.4.4 is okay, probably introduced in 1.4.5)
    Browsers: Chrome 45 (ngMessages), IE11 (ngMessages, ngIf), FF 39 (ngMessages, ngIf) @ Windows 8.1 home

    Interesting thing is that if you try the second form on this Angular Material demo page: https://material.angularjs.org/0.11.2/#/demo/material.components.input
    The issue does not occur on the Client Name input, but appears on Client Email (I have no theory why.)

  8. 26 remaining items

  9. modified the milestones: 1.5.1, 1.4.10 on Jan 28, 2016
  10. bathos commented on Feb 14, 2016

    @bathos

    I encountered this, too. The exit animation is fine, but before the enter animation runs, all ng-messages momentarily display (tested Chrome, FF). Reading through the comments so far, is it correct that there is no known way around this if you're in 1.4.x, except to animate manually?

    ng-message {
        display: block;
        margin: 1rem 0;
        transition: max-height linear $fast;
    
        &.ng-enter {
            max-height: 0;
            overflow: hidden;
    
            &.ng-enter-active {
                max-height: 2.5rem;
            }
        }
    
        &.ng-leave {
            max-height: 2.5rem;
            overflow: hidden;
    
            &.ng-leave-active {
                max-height: 0;
            }
        }
    }
    

    Edit: in my case, I was able to solve it in cases where there is only going to ever be one ng-message by adding this:

    .ng-inactive > ng-message:not(.ng-leave) {
        display: none;
    }
    

    This does successfully keep the message unshown during the would-be flicker. However you need the :not(.ng-leave) there or else it will also dump your exit animation. Unfortunately I don't think this will help except in cases like mine, where there's only ever one ng-message at a time.

  11. Narretz commented on Feb 15, 2016

    @Narretz
    Contributor

    We've decided to backport the ng-[event]-prepare class back to 1.4.x, and it will be available in the upcoming 1.4.10

  12. modified the milestones: 1.4.x, 1.5.1 on Feb 15, 2016
  13. Narretz commented on Feb 15, 2016

    @Narretz
    Contributor

    I'm not sure if we can ever provide a "real" fix, since the animation spacing is so essential to ngAnimate now. Moving to the backlog for now.

  14. modified the milestones: , 1.4.x on Feb 15, 2016
  15. jaszczakBartosz commented on Jul 19, 2016

    @jaszczakBartosz

    This worked for me:

    .ng-enter-prepare
      display: none
    
  16. topherfangio commented on Jul 19, 2016

    @topherfangio
    Author

    @Unasbj Indeed; this new class was added in more recent versions and allows you to work around this bug.

    @Narretz I think this can be closed now?

  17. C-E-Rios commented on Dec 7, 2016

    @C-E-Rios

    This is still an issue for me. I've tried some of the workarounds suggested but none work. Maybe I'm missing something?

    https://plnkr.co/edit/XYq1wF7la97dIz9Ec33J?p=preview

  18. gkalpak commented on Dec 7, 2016

    @gkalpak
    Member

    @C-E-Rios, you could replace ngShow with ngIf on the [ng-message] elements (and don't need any -prepare styles).
    (But from a quick look, yours is a different issue than what is being discussed here.)

  19. C-E-Rios commented on Dec 7, 2016

    @C-E-Rios

    @gkalpak - Awesome that does the trick. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions