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.

md-input-container not showing error ng-messages  #6767

Closed

Description

@vlio20

Hi,
There are cases when the error message (ng-message) not showing, try to play with the codepen below.
the input field is required and minlength set to 2:
http://codepen.io/vlio20/pen/KVybvx?editors=110

Steps to reproduce:

  1. focus on input.
  2. enter 1 char & focus out (blur) -> minlength error message is displayed.
  3. delete the char from step 2 -> no message is displayed, when the required message should have been displayed.

Note-1: The form is invalid with correct message

Note-2: in happens for other validations as well (other then required and minlength).
If I am overriding the styles like bellow, it seems to be working, but the animations are not good when the error message is changed:

md-input-container.md-input-invalid .md-auto-hide .md-input-message-animation:not(.ng-animate) {
  opacity: 1;
  margin-top: 0;
}

md-input-container.md-input-invalid [ng-messages] {
  max-height: 19px;
}

I am using 1.0.2 version, but it seems to be broken since 1.0.0

Activity

  1. changed the title [-]md-input-container not showing error messages [/-] [+]md-input-container not showing error ng-messages [/+] on Jan 19, 2016
  2. persimmons commented on Jan 20, 2016

    @persimmons

    update: codepen

    +1 - I am doing custom messaging for server-side errors with ng-messages using an md-input-container, and I'm running into the same issue.

    <md-input-container>
      <div ng-messages="vm.loginServerErrors"
           role="alert">
        <div ng-message="loginFailed">
          Oops! That username and password combination was incorrect.
        </div>
      </div>
    </md-input-container>
    

    This code worked with v0.11, but no longer works after bumping to 1.0. Looking into the DOM on the rendered page, the class md-auto-hide is getting applied to the ng-messages div. Removing this class restores the original behavior.

  3. vlio20 commented on Jan 20, 2016

    @vlio20
    Author

    @keithajackson, did you add some custom code to fix this?

  4. persimmons commented on Jan 20, 2016

    @persimmons

    @vilo20 I was hoping to avoid it, but it's looking like I have to override a CSS style to make a workaround:

    The offending rules (which are getting applied to the ng-message children, not the ng-messages parent, are:

    md-input-container .md-auto-hide .md-input-message-animation:not(.ng-animate) {
        opacity: 0;
        margin-top: -100px;
    }
    md-input-container:not(.md-input-invalid) .md-auto-hide .md-input-message-animation {
        opacity: 0;
        margin-top: -100px;
    }
  5. persimmons commented on Jan 20, 2016

    @persimmons

    update: codepen with fix

    GOT IT. I needed to disable auto-hiding on my ng-messages div, changing:

    <div ng-messages="rgn.loginServerErrors" role="alert">
    

    to

    <div ng-messages="rgn.loginServerErrors" role="alert" md-auto-hide="false">
    

    The md-input docs note that messages will automatically be hidden until the md-input-container sets an md-is-error expression. Since my use case doesn't use md-input-container for anything besides (essentially) styling, I'm handling the visibility myself through JS.

  6. persimmons commented on Jan 20, 2016

    @persimmons

    Workaround: I made a somewhat fixed codepen off your issue, @vlio20 , by handling the visibility myself:

    <div ng-messages="registrationForm.agencyName.$error" md-auto-hide="false" ng-if="registrationForm.agencyName.$touched">

    The animations get weird, though when I follow the steps to reproduce. Both errors become visible for a moment, and then the minlength error disappears without an animation.

  7. vlio20 commented on Jan 20, 2016

    @vlio20
    Author

    @keithajackson, yea it worked! thanks!!! I think it should be the default behavior.
    Now I have very long html tags :(

    Thanks @keithajackson, I will close this issue.

  8. persimmons commented on Jan 20, 2016

    @persimmons

    @vlio20 I think we should keep this open. The workaround fix still results in broken animations, so I think the underlying feature has a bug.

    Open codepen, then:

    1. focus on input.
    2. enter 1 char & focus out (blur) -> minlength error message is displayed.
    3. delete the char from step 2 -> second message slides in, bumping elements down. Then the first message disappears, snapping everything back up.
  9. reopened this on Jan 20, 2016
  10. brunsgaard commented on Jan 21, 2016

    @brunsgaard

    Hi guys, thanks for the workaround. Keep the issue open I just ended up here having the same problem as you guys. Lets hope for a real fix soon that will also fix the animation.

  11. ThomasBurleson commented on Jan 27, 2016

    @ThomasBurleson
    Contributor

    A full, valid PR would be welcomed.

  12. added
    P4: minor
    on Jan 27, 2016
  13. added this to the milestone on Jan 27, 2016
  14. 78 remaining items

  15. jellyfush commented on Mar 21, 2017

    @jellyfush

    I have a similar problem with firefox 52.0 on ubuntu, Chrome is fine. See http://codepen.io/anon/pen/vxRpJK the error shows then disappears.

  16. jellyfush commented on Jul 10, 2017

    @jellyfush

    Its a bit of a pain but I found it best just to not use ng-message for server side errors in this case, I just use a loop/switch to display them styled the same way... similar to the way the document say's to display info underneath

  17. jellyfush commented on Jul 11, 2017

    @jellyfush

    @bruno-serfe Yea its kind of frustrating. Seems like some weird thing with the animation setting the opacity to 0 when finishing, could actually be an angular bug but haven’t looked into it enough.

    If you wanted to do something similar to the ng-message you could reference this https://codepen.io/anon/pen/dRwXQE you could put a switch in there to render the message the way you want. Seems like a bit of an ugly hack, but works form me.

    Of course if you were getting errors back from the server I would remove the ng-if and just have it print the returned error. Can be used in combination with ng-message but it looks as though only one can be active at a time otherwise they sit on top of each other

  18. added a commit that references this issue on Jul 18, 2017
    0151b4b
  19. beany-vu commented on Nov 18, 2017

    @beany-vu

    I also faced the issue. If I set the form's name with dash character "-", then it didn't show the error message. However, when I changed to camel case, it's okay.

  20. dmitryrogov commented on Dec 1, 2017

    @dmitryrogov

    I had a similar problem. As it turned out, one form was inside another one. Check your page layout

  21. Talhah commented on Apr 3, 2018

    @Talhah

    I have finally found a solution that works for me with the help of @topherfangio

    https://codepen.io/talhahm/pen/EEpyqv

  22. locked as resolved and limited conversation to collaborators on Feb 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P4: minorhas: Pull Requestresolution: fixed

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions