-
Notifications
You must be signed in to change notification settings - Fork 291
Issue with grouped checkboxes in firefox #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Just tested with FF 29.0.1 on MacOSX Mavericks: Its even worse: After deselecting postcard, the green tick remains. On Chrome the "x This field is required" message appears. |
Can reproduce this error with FF 34.0 |
I'm having no joy fixing it, accept for wrapping the 'validate' function (the 'change' handler in the validateMultipleFields directive) logic in a $timeout to force a ui re-render. But this intermittently causes a flicker in FF where the error message shows first before the tick displays. If you inspect all the values and object states (form and fields) when the 'change' handler fires they're correct. As are the css classes applied to the form and fields. It just looks like FF is rendering the page before they're fully updated. |
I've put together a paired down plunker just to make sure that the issue occurs in isolation. http://plnkr.co/edit/5abVpPofLytqEgE4qZlV?p=preview This is a potential (not 100% satisfactory) fix using $timeout. The flicker occurs the first time a checkbox is clicked. |
I've implemented a fix by using http://plnkr.co/edit/eIBMo4KWOWiOT55JqjR0?p=preview I'm presuming the issue is caused by the fact that firefox dispatches it's 'click' and 'change' events in the opposite order to every other browser (click first) and the click is possibly causing the digest cycle to run before the values have all been updated. I'm afraid i don't have enough experience with django forms to confidently implement this fix myself, as i'm not sure of all the combinations of elements/widgets it affects? |
…emoved from anywhere
…jected, true) modifies the error array
…d of elements, so that rejected errors can be cleared
…r child ng-change
Ok, this is a pure angular based fix, no mods to the python. I've fixed the two bugs i originally listed and fixed a couple of other issues i've come across in the |
@@ -137,40 +137,63 @@ djng_forms_module.directive('ngModel', function() { | |||
}); | |||
|
|||
|
|||
djng_forms_module.directive('validateMultipleFields', function() { | |||
djng_forms_module.directive('validateMultipleFields', function($parse) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without ['$parse', function($parse) {
this file can't by uglyfied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, i use ng-annotate with gulp, so completely forgot to add the uglify safe injections.
I need some time to understand your code. Please be patient. Made some annotations. |
No problem, whenever you get to it. I was just cleaning up my comments from yesterday to make sure they where as clear and concise as possible. |
Issue with grouped checkboxes in firefox
Sorry, for for the delay. |
BTW, PR #144 will soon be merged and we will release version 0.8.0. |
Today, in another project I used the form validation for multiple fields. |
Can you be a bit more specific? What exactly was the major problem that it caused? I didn't realise manipulating the DOM in that way was considered an anti-pattern? What makes it an anti-pattern? Can you point me in the direction of an explanation of this, thanks? |
I don't like, that a directive adds other ng-... directives to the DOM and I strongly believe that this use case was not intended by the Angular team. Just revered your PR from December. However, I now fixed the FF issue myself in a much cleaner and simpler way. Please recheck with your installation. What was missing for FF, was the |
If you look at my comments you'll see that the first quick fix i came up with for this issue, was to simply wrap the The problem i have with the quick fix of That aside, i can understand how you might wrongly consider my solution using Within angular an inputs current state is represented by its Regardless of how Also going forward, the current solution causes issues when |
One other thing. The reversion has reintroduced an issue. If you submit the form via ajax with no inputs selected for 'Notify by', the rejected error message is correctly displayed. If you then select a checkbox, the error message disappears, but the valid tick never re-appears, as the parent So at line 155, below
you need to add
Also each child fields 'rejected' |
Since I use the jQuery The big problem I had with your solution was, that I added a
Thanks for reporting the seconds issue. What's that 'rejected' property? This is not part of the form errors, so I did not understand its purpose. |
'rejected' is part of the |
@jrief Just to clarify why 'rejected' needs to be removed from the form in this instance. When 'rejected' errors are applied in the
Using the example form as an example, a 'required' error is returned for the So in this block of logic from the above code (your original code, not a later addition) , the
This is the same You can see this on the demo form by following these steps: http://djangular.aws.awesto.com/combined_validation/
Returning to this point, i'm not sure what purpose it serves also adding the
|
@jamesbrobb |
I've added it to my profile |
#160 offers an alternative fix for everything mentioned in this issue |
Can someone comfirm this please. I'm using:
OSX 10.7.5
Firefox 33.1.1
http://djangular.aws.awesto.com/form_validation/
or
http://djangular.aws.awesto.com/combined_validation/
Scroll to 'notify me' and select 'postcard' -- i get the 'required' error message
deselect 'postcard' -- i get the valid tick
select more than one checkbox in the group and the valid tick appears
deselect all and the tick stays until you reselect one
Also, once you've force submitted the form to ajax (in any browser) with no checkboxes selected, the valid tick does not appear once any checkboxes are selected.