-
-
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
submitting paper-form with enter key #460
Comments
Sorry I had the action still in the paper-button |
<form onsubmit={{action form.onSubmit}}> should also work. I'm open to suggestions on how this could be made easier. |
It would be nice to have enter key submission "just work" by default. If that means generating a form tag, is there any downside? |
Possibly some style issues can arise. The markup won't be the same. |
If you're unsure, then just maybe just add a section to the docs? |
I think the benefits outweigh the cons (if any). So, I could take a PR for this + tests. :) |
@miguelcobain Sorry but I don't think I'll have time. I've moved onto a new project. |
@shoxter what is your opinion on this? |
@miguelcobain I think it's a good idea. What if we add an action to the form that looks for the enter key being pressed (the event is passed in) and set the input(s) the user wants to have access to it to having the submit action (i.e. |
@shoxter another idea would be to use
|
@miguelcobain The primary issue I foresee as being problematic is styling. For example, in my personal application I wrap entire It's very flexible without a tag. This goes away when we add one. Do you have any alternative methods off the top of your head? If not, I'll think on it and see what I can come up with. |
Would it be harmful for styles to have a form tag in your dialog? We should be doing it any way for semantics/acessibility. |
I think tagless is much more flexible, especially if the other use case can be achieved by just adding a form tag. |
Any progress on this subject ? When I try the following: {{#paper-form onSubmit=(action 'submit') as |form|}}
<form class="layout-row" {{action form.onSubmit on='submit'}}>
{{form.input placeholder='placeholder' value=value onChange=(action (mutvalue))}}
{{#form.submit-button raised=true primary=true type='submit'}}Submit{{/form.submit-button}}
</form>
{{/paper-form}} Using the latest alpha release I get:
I'm left wondering how to properly use |
@panthony did you check the docs on paper-form? http://miguelcobain.github.io/ember-paper/release-1/#/forms |
I did check the docs but a form done this way cannot be submitted by pressing enter. Or at least it did not for me. The warning comes from this for me: {{#paper-form onSubmit="submit" as |form|}}
<form {{action form.onSubmit on="submit"}}> But since the comment is rather old I was wondering if it was still the way to do it. I ended up ignoring the 'onSubmit' attribute of the {{#paper-form |form|}}
<form class="layout-row" {{action (action 'submit') on='submit'}}> I think the only thing i loose is the submit action that does not fire if an input is invalid. |
@panthony doesn't this work for you? {{#paper-form onSubmit="submit" as |form|}}
<form onsubmit={{action form.onSubmit}}>
{{form.input label="Name" value=name onChange=(action (mut name)) required=true}}
{{#form.submit-button raised=true primary=true}}
Submit
{{/form.submit-button}}
</form>
{{/paper-form}} |
@miguelcobain No it does not work.
I can fix the later by adding |
Makes sense. We aren't setting type to "submit" in our yielded button. Can you please PR that |
@miguelcobain done with #568 |
To add some additional information to this thread, when using:
and submitting my form, the url that's submitted is something like However, using Also, the deprecation still remains regardless. |
@jamesdixon you probably need to preventDefault on the first approach. Can you try that? |
@miguelcobain ill give it a try. thank you! |
Working like a charm :) Thanks @jamesdixon |
@miguelcobain
The page will be 'reloaded' when hit the enter button... using |
@BennyAlex Why are you
This is maybe due to the |
@miguelcobain Of course I tried false and true, both doesnt work. Also of reading this guide https://guides.emberjs.com/v2.10.0/templates/actions/, ember should prevent the default browser action by default... |
as you can see in this twiddle, element space actions (like in that guide) are default prevented, but closure actions like https://ember-twiddle.com/c51d320ba02b121537dae467458fb6dd?openFiles=templates.application.hbs%2C paper-form may need to be refactored so that this use case works out of the box :/ |
@miguelcobain Here is my code:
|
This issue seems resolved, maybe this ticket can be closed? |
I just spent a lot of hours trying to make my paper-form component using 1.0.0.alpha.3 submit with the enter key and in the end I found the magical incantation, but I'm left wondering if maybe paper-form should make this easier, or at least document it.
Here is the only way I could make it work:
The text was updated successfully, but these errors were encountered: