Skip to content
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

Merged
merged 5 commits into from
Feb 21, 2017

Conversation

tyleryasaka
Copy link
Contributor

My second attempt at solving #460, this time by making paper-form an html form.

Some things to note:

  • Pressing the enter key to select an item in a paper-autocomplete (as well as a paper-select I assume) will submit the form - probably not ideal behavior. I attempted to find a simple way to prevent the enter keypress event from propagating when an item in the dropdown is selected, but I wasn't able to find a solution without hacking into ember-power-select. But maybe I missed something.
  • I wasn't able to actually write a test for pressing the enter key in a form. From what I can tell this isn't possible with jQuery. Instead, I tested that the onSubmit action is called when an input of type submit within the form is clicked. This gives us some test coverage to make sure paper-form is in fact a real html form.

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.
@miguelcobain
Copy link
Collaborator

@tyleryasaka this looks good.

Can you please update the docs to reflect this change?

@tyleryasaka
Copy link
Contributor Author

tyleryasaka commented Feb 21, 2017

@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>
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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".

Copy link
Contributor Author

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. 👍

@miguelcobain miguelcobain merged commit 84f7da5 into adopted-ember-addons:master Feb 21, 2017
@miguelcobain
Copy link
Collaborator

It was merged. Thanks. :)

@tyleryasaka
Copy link
Contributor Author

😃

backspace added a commit to backspace/prison-rideshare-ui that referenced this pull request Apr 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants