-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
Ionic 4 Button does not trigger ngSubmit #15136
Comments
Can you update to beta.2 and try again? |
I'm using beta.2 and submit buttons still do not trigger ngSubmit on the enclosing form.
The template I'm using (which worked in ionic3):
|
I'm also seeing this issue.
Here is my form:
The |
@manucorporat updated to the following with no change, unfortunately.
|
@manucorporat Still broken with Beta 3.
|
This is happening for me in Chrome (Version 68.0.3440.106 (Official Build) (64-bit)). After noticing an issue with |
This is issue should be resolved in beta.17. If I am wrong, please write here! |
I've updated to beta.17 and confirmed the problem still exists.
Here's how you can reproduce it:
This is my first comment on GitHub, so let me know if I missed anything you need. Thanks |
@codybeebework Thanks for your response and your time to add this :) But I think you missed something because it should work like you described. See my repo -> https://github.com/paulstelzer/test-ionic UPDATE: AHHH - You said when you hit enter. That's something completely different. Ionic 4 uses shadow dom, so the native input element is not available. You have to add such a feature yourself by adding |
The title of this issue and OP's steps to reproduce (step 2) are not in agreement so no worries. We came to the same conclusion, using keyup.enter to mimic what a normal html form provides. I've pulled your git repo and was able to confirm that the keyup events for enter were giving the desired effect, and reveals the same bug I ran into. This breaks what was already working in Microsoft Edge. Before adding the keyup events to the input fields, Edge was recognizing hitting enter as a form submission. After adding the events, Edge will fire the form submission twice: once for the normal html form submission and once again because of our manual event being fired. I'm still new to what the Shadow DOM provides and restricts, but I was under the impression that it is related only to styling, not functionality. If that's not the case, how might Edge be ignoring it? To add more to the work around, you can remove If it is not because of the Shadow DOM, then I hope this could be fixed in a future Ionic update. Thanks for the quick response. |
Ah thanks for this good answer! The reason for this: Edge is not using Shadow DOM, so there it's all plain. That's the reason why the normal input enter is working there. But the good news is that Edge (better EdgeHTML) will be removed in future :D They also will use Chromium. But all older browsers without shadow dom (e.g. Firefix <63) also affected. I think we have to find a solution for it. One could be do add a variable to the function that will be set to true / false (isSubmitted). Not a good workaround, but a workaround. I will share it with the Ionic dev team if there is another (better) solution. |
I close this for now because it should fixed with #17043 . After rc.2 release you can check again and if it still not working, just create a comment here and I reopen. I tested it already with the latest master and it works. You just have to keep in mind that it only works with one input to press enter (workaround here -> https://stackoverflow.com/questions/6317761/pressing-enter-submits-html-form-with-one-input-but-not-two), but that is all related to HTML / browser and not Ionic |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Bug Report
Ionic Info
Describe the Bug
<ion-button type="submit">
does not trigger NgFormngSubmit
any longer after upgrading to ionic 4. The intended behavior is referenced in the previous version here: https://ionicframework.com/docs/developer-resources/forms/Steps to Reproduce
Steps to reproduce the behavior:
<form (ngSubmit)="onSignup(form)" #form="ngForm">
containing<ion-button expand="full" type="submit">Sign up</ion-button>
onSignup
is not triggered.Related Code
The previous behavior that should happen is referenced here: https://ionicframework.com/docs/developer-resources/forms/
Expected Behavior
ngSubmit
event to be triggered on either submiting form by enter keypress or by clicking the submit button.The text was updated successfully, but these errors were encountered: