ENTER key does not trigger form submission (ngSubmit)
See original GitHub issueIf an input using currencyMask is focused and we press ENTER, form submission does not work. (any other input without currencyMask will trigger ngSubmit correctly)
Maybe i’m wrong, but it looks like the problem is occurring here
Simple Example
Component
import { Component } from "@angular/core";
import { FormBuilder, FormGroup } from "@angular/forms";
@Component({
selector: "my-app",
templateUrl: "./app.component.html"
})
export class AppComponent {
public form: FormGroup;
constructor(private fb: FormBuilder) {
this.form = this.fb.group({
inputWithMask: 10000,
otherInput: 10000,
});
}
save() {
console.log("SAVE WORK");
}
}
HTML
<div class="card">
<div class="card-body">
<form [formGroup]="form" (ngSubmit)="save()">
<div class="form-group">
<label>Enter will not work here</label>
<input type="text" class="form-control" currencyMask formControlName="inputWithMask" />
</div>
<div class="form-group">
<label>Enter works</label>
<input type="text" class="form-control" formControlName="otherInput" />
</div>
<button type="submit" class="btn btn-primary"> Press ENTER </button>
</form>
</div>
</div>
package.json
"dependencies": {
"@angular/animations": "^10.0.9",
"@angular/common": "^10.0.9",
"@angular/compiler": "^10.0.9",
"@angular/core": "^10.0.9",
"@angular/forms": "^10.0.9",
"@angular/platform-browser": "^10.0.9",
"@angular/platform-browser-dynamic": "^10.0.9",
"@angular/router": "^10.0.9",
"ngx-currency": "^2.5.2",
"rxjs": "^6.6.2",
"tslib": "^2.0.1",
"zone.js": "^0.10.3"
}
I also tested with angular 9 and ngx-currency 2.3.3 / 2.4.1 and latest 2.5.2
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:6
Top Results From Across the Web
Preventing form submission on Enter key press in Angular
It can have client-side scripts associated with the element's events, which are triggered when the events occur. button: the button has no ......
Read more >Submitting the form by pressing Enter key in Angular - Reactgo
In this tutorial, we are going to learn about how to submit the form by pressing an enter key inside the input field...
Read more >enter key to trigger ng:click on "submit" button - Google Groups
Hi,. I just tried this in 1.0rc0 and the enter key is not triggering the submit. Here is an updated ...
Read more >How to submit form on pressing Enter with Angular 9?
Approach: We can use angular keydown event to use Enter key as our submit key. Add keydown directive inside the form tag.
Read more >How to Disable Enter Key to Submit Form in Angular?
Here, i will show how to stop submit form using enter key in ... <h1>How to check form is valid or not in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Here is the link with the solution using (keyup.enter) : https://stackblitz.com/edit/angular-rzxzkx?file=src/app/app.component.html
Thank you!