-
Notifications
You must be signed in to change notification settings - Fork 27.5k
form and input is getting dirty by clicking on a simple button #7457
Comments
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#attr-button-type
Basically, when you don't give your button a type, it defaults to "submit", and angular's submission handler causes the form to be dirty'd. You have an easy work around, just give the button a type, like @petebacondarwin / @matsko should we be dirtying the form on submit if it doesn't change? that seems weird. |
Thank you for your answer. And yes, that seems to be not the expected behaviour to me. We are setting classes in dependence a form element is touched by the user. Therefore it seems to be weird to set the form and the elements dirty if nothing was edited. |
@caitp @petebacondarwin the form is becoming dirty due my bug in a0ae07b ( |
Thanks @shahata |
…as changed Calling `$commitViewValue` was was dirtying the input, even if no update to the view value was made. For example, `updateOn` triggers and form submit may call `$commitViewValue` even if the the view value had not changed. Closes angular#7457 Closes angular#7495
I am using angular-js 1.6.4 and I am getting the same problem. May be the issue re-appeared. I fixed it by setting my buttons type to be button instead of submit, but the issue marked as closed so I should not need to have done it, right? |
@NaomiN the original issue is not broken with 1.6.4. See http://plnkr.co/edit/EAAdJScYtRJKich5FJQs?p=preview If you are experiencing a different issue then please can you create a new issue with a reproduction. |
In the original plunker I made a single change - the input type="number" to demonstrate the problem. The problem only shows for input type="number" and buttons. I made a google search and found this issue. So my solution was to use button type="button" |
I just tried that on my new plunker and it still doesn't mark it as dirty. |
Weird, I can no longer reproduce myself there even though it marked as dirty this morning. I know I spent several hours last night trying to figure out the problem with my form before landing on this issue. |
Create a simple form with an input and a button without any functionality. Clicking the button results in setting the form and the input to dirty.
To illustrate the behaviour I made a plunkr:
http://plnkr.co/edit/GlLD83K8OLVIShPlfENm?p=preview
Best regards
westor21
The text was updated successfully, but these errors were encountered: