-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Bug: Firefox: Input fields with 'required' get red shadow/border before submitting #12102
Comments
I don't really see that being a problem with angular but with firefox |
@timjacobi: Your link applies to disabling the red shadow entirely (i.e. after form submission too). The only (sort-of) relevant discussion I found is here: http://stackoverflow.com/questions/17209057/firefox-draws-red-border-on-required-select-box/30812303 My suggestion: Apply a class Reason: When clicking the submit button without ever focussing somewhere else, the ng-classes don't change at all. Therefore, the status "form was just rendered" and the status "user has already tried to submit" can't be distinguished in CSS - that's why all work-arounds like this don't really work: (I'm talking about the situation where |
You have to disable the native browser validation. Eg. |
Come on, what kind of answer is that? Now, seriously, is it an official system requirement for AngularJS to disable native browser validation? I thought it was just a recommendation? In my opinion there are valid reasons to keep native browser validation - e.g. not having to bother with designing/styling error messages. AngularJS is promoted to reduce programmers' work, not to increase it (from homepage: "Write less code, go have beer sooner."). So if you are not going to fix this, it's certainly a case of "Write more code".... So please reopen this. |
@ThomasLandauer I am not trying to tell you what do to and what not to do. The same red border is present if you put |
Let me open this and try to see if it is possible to work around this Firefox limitation |
As explained above: The red border is only there if all three conditions are met (i.e. AngularJS is active): Check out the fiddle, remove |
Do not trigger Firefox validation on form initialization. - Do not set a value to an <input> field if the field already has the same value Closes angular#12102
@ThomasLandauer this is an issue with Firefox, Firefox code triggers the form validation when setting an element value using JavaScript and the value is the same as the current value. Created #12106 to handle this case, but the fix would only work for jqLite (a different workaround would be needed for jQuery). The fact that you need Angular to trigger this behavior does not imply that this is an Angular issue as it is possible to trigger the same behavior without Angular. |
Still in doubt? Updated fiddle not using any Angular. |
https://jsfiddle.net/5yh58orm/17/ is equivalent to the example that @timjacobi posted, but clearly shows this is a Firefox issue |
FWIW, there IS an |
Do not trigger Firefox validation on form initialization. - Do not set a value to an <input> field if the field already has the same value Closes angular#12102
@lgalfaso: I wouldn't call it a Firefox issue, but rather an incompability between Firefox and Anulgar ;-) But anyway, thanks for opening the other issue!! :-) @gkalpak: Yeah, thanks, I noticed that meanwhile ;-) BUT: |
@ThomasLandauer, I see what you mean about adding a class to indicate unsuccessful submitting. But I don't think this is a widely used/needed option. Note that several people have requested different classes to be added by That said, it is pretty easy to implement any extra functionality outside of the core. |
Yeah sure, you certainly can't add a class for everything ;-) But generally, I prefer native browser functionality over anything self-designed, cause it gives a better user experience. In this case: Firefoxes native red shadow & popup tooltip is familiar to the user (cause they've probably seen it a hundred times before), my design is new to the user. Well, the issue is on file anyway, so if anybody wants it too, please leave a comment. And if I'm the only one, forget about it ;-) |
Do not trigger Firefox validation on form initialization. - Do not set a value to an <input> field if the field already has the same value Closes angular#12102
Do not trigger Firefox validation on form initialization. - Do not set a value to an <input> field if the field already has the same value Closes angular#12102
Do not trigger Firefox validation on form initialization. - Do not set a value to an <input> field if the field already has the same value Closes angular#12102
Thanks for working on this! This now works for all input fields except text area. Can you fix that too? [EDIT] I fixed this temporarily by defining this CSS style to all my text area fields: |
@eyahlin, since this issue is closed, please open a new one (referencing this one if related). Also providing a live demo of the problem helps a lot 😃 Thx! |
I have submitted a Firefox bug report as I experienced it outside of Angular: |
A same thing with primeng in angular 2. The point is put one or if necessary two,three classes to overwrate strong primeng classes. Put two of self class after them put some primeng class |
Confirmed this is outside Angular, I'm having it with React and Material-UI (via Formsy). |
For anyone else trying to circumvent this, you can override the default Firefox browser styling: :-moz-ui-invalid:not(output) { (Obviously the not on the output element is optional). |
|
Firefox 38.0.5
AngularJS 1.4.0
input
fields get the red invalid border/shadow on pageload (i.e. before the form is submitted), if all three conditions are met:ng-app
definedng-model
set to any namerequired
attribute presentHere's a fiddle: https://jsfiddle.net/5yh58orm/11/
In Chrome 43.0 and Internet Explorer 11 there is (as expected) no border.
The text was updated successfully, but these errors were encountered: