-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(ngForm): don't block submit when method=dialog #12882
base: v1.4.x
Are you sure you want to change the base?
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I signed it! |
CLAs look good, thanks! |
Shocking support for that element: http://caniuse.com/#feat=dialog
|
@@ -485,7 +485,7 @@ var formDirectiveFactory = function(isNgForm) { | |||
var controller = ctrls[0]; | |||
|
|||
// if `action` attr is not present on the form, prevent the default action (submission) | |||
if (!('action' in attr)) { | |||
if (!('action' in attr) && attr['method'] !== 'dialog') { |
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.
What happens when the action attr is set and method is set to dialog?
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.
According to the spec, if method is dialog then it closes the dialog and stops further processing. The action attribute should be ignored by the browser in that case.
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.
What I meant is: if the action attribute is set and the method is set to dialog, your code change would not prevent the submit. Isn't !('action' in attr) || attr['method'] !== 'dialog'
what we want?
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.
Ah, I think I misunderstood the purpose. I though it should block submit when the method is dialog, doh. Having the test really helps understanding what a change is about.
When a form's method is set to "dialog" it does not post to a server but instead closes the nearest parent <dialog> element. An action is not required.
I've added a test and updated the comments. I'm not sure that blocking submit when method="dialog" with an action is what we want? It should be up to the browser to handle that properly. |
Thanks for the test. Now that method="dialog" does not block submit anymore, I think we'd still want to have it call $commitViewValue and $setSubmitted on the form, right? Previously, it would set these only if the form wasn't sent to the server. Now the form isn't sent to the server, so I assume we still want that. |
When a form's method is set to "dialog" it does not post to a server but instead closes the nearest parent element. An action is not required.
https://html.spec.whatwg.org/multipage/forms.html#submit-dialog