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

Hitting Enter on a ReactiveForm that uses ngSubmit clears out the input making it invalid #68

Open
jacques-hoventer opened this issue Oct 8, 2020 · 0 comments

Comments

@jacques-hoventer
Copy link

I have a very simple form with a one ngx-mat-file-input and another text infput:

Add file clear
    <mat-form-field>
        <mat-label>Rename file</mat-label>
        <input type="text" formControlName="newFileName" matInput placeholder="E.g. My ID">
    </mat-form-field>

    <button [disabled]="!entityForm.valid" type="submit" mat-flat-button color="accent">Add file</button>

Using the Submit button fires the onAddFile eventhandler, but if the user has focus on the Rename input field and presses the Enter key after having:

  1. Selected a file
  2. Entered a value for Rename
    The onAddFile eventhandler isn't fired and the ngx-mat-file-input selected file is cleared out.

Also confirmed is that the reactive form has no value for the file field:
this.entryForm.controls.file.value is ""
this.entryForm.controls.file.status is "invalid"

Angular => 10.1.4

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

No branches or pull requests

1 participant