-
-
Notifications
You must be signed in to change notification settings - Fork 333
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
Makes paper-form an actual html form #649
Conversation
This prevents the form from being submitted twice when a contextual paper-form submit-button is clicked.
…orm submission. Since paper-form is now an html form, this causes the form to be submitted twice (as html buttons automatically submit forms). The purpose of this test is to check that the contextual onSubmit action works, so using an `a` tag works just as well.
@tyleryasaka this looks good. Can you please update the docs to reflect this change? |
@miguelcobain updated the docs. How does that look? |
@@ -50,12 +50,12 @@ test('form `onSubmit` action is invoked', function(assert) { | |||
{{form.input value=foo onChange=(action (mut foo)) label="Foo"}} | |||
{{form.input value=bar onChange=(action (mut bar)) label="Bar"}} | |||
|
|||
<button onclick={{action form.onSubmit}}>Submit</button> | |||
<a {{action form.onSubmit}}>Submit</a> |
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.
Do we need to change this to an <a
?
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.
@miguelcobain It needs to be something besides button
, because html buttons submit forms automatically. When it's a button here, the onSubmit
action is called twice. Once because the action is assigned directly to the button, and once because of the form's submit
handler.
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.
@tyleryasaka That's what happens by default, but I changed it to <button type="button"
.
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 ok - I didn't realize that could be done. 👍
It was merged. Thanks. :) |
😃 |
This was fixed here: adopted-ember-addons/ember-paper#649
My second attempt at solving #460, this time by making
paper-form
an html form.Some things to note:
paper-autocomplete
(as well as apaper-select
I assume) will submit the form - probably not ideal behavior. I attempted to find a simple way to prevent theenter
keypress event from propagating when an item in the dropdown is selected, but I wasn't able to find a solution without hacking intoember-power-select
. But maybe I missed something.onSubmit
action is called when an input of type submit within the form is clicked. This gives us some test coverage to make surepaper-form
is in fact a real html form.