You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
Repository navigation
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
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:
focus on input.
enter 1 char & focus out (blur) -> minlength error message is displayed.
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:
I am using 1.0.2 version, but it seems to be broken since 1.0.0
Reacted by Andres Araujo, Uku Lagle, Aaron, Peter Leibiger, Darko Penev, Jonas Brunsgaard, Netanel Draiman, Zach Bjornson, Brian Feister, Patrick Zhong and 12 more
+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.
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.
Reacted by Patrick Zhong, Prateek, Victor Basurto, Rémy Testa, ThomasStubbe and Ryan Stecher
Reacted by Andrea Puddu, Simon and Gilles Lepretre
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.
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.
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
@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
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.
Activity
[-]md-input-container not showing error messages [/-][+]md-input-container not showing error ng-messages [/+]persimmons commentedon Jan 20, 2016
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.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-hideis getting applied to theng-messagesdiv. Removing this class restores the original behavior.vlio20 commentedon Jan 20, 2016
@keithajackson, did you add some custom code to fix this?
persimmons commentedon Jan 20, 2016
@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-messagechildren, not theng-messagesparent, are:persimmons commentedon Jan 20, 2016
update: codepen with fix
GOT IT. I needed to disable auto-hiding on my
ng-messagesdiv, changing:to
The md-input docs note that messages will automatically be hidden until the
md-input-containersets anmd-is-errorexpression. Since my use case doesn't usemd-input-containerfor anything besides (essentially) styling, I'm handling the visibility myself through JS.persimmons commentedon Jan 20, 2016
Workaround: I made a somewhat fixed codepen off your issue, @vlio20 , by handling the visibility myself:
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.
vlio20 commentedon Jan 20, 2016
@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.
persimmons commentedon Jan 20, 2016
@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:
brunsgaard commentedon Jan 21, 2016
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.
ThomasBurleson commentedon Jan 27, 2016
A full, valid PR would be welcomed.
78 remaining items
jellyfush commentedon Mar 21, 2017
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.
jellyfush commentedon Jul 10, 2017
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
jellyfush commentedon Jul 11, 2017
@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
fix(input): correct initial animation state of messages (#10246)
beany-vu commentedon Nov 18, 2017
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.
dmitryrogov commentedon Dec 1, 2017
I had a similar problem. As it turned out, one form was inside another one. Check your page layout
Talhah commentedon Apr 3, 2018
I have finally found a solution that works for me with the help of @topherfangio
https://codepen.io/talhahm/pen/EEpyqv