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

Using MatDialogClose breaks default form submit functionality #16909

Closed
flauc opened this issue Aug 29, 2019 · 5 comments
Closed

Using MatDialogClose breaks default form submit functionality #16909

flauc opened this issue Aug 29, 2019 · 5 comments
Labels
help wanted The team would appreciate a PR from the community to address this issue P5 The team acknowledges the request but does not plan to address it, it remains open for discussion

Comments

@flauc
Copy link
Contributor

flauc commented Aug 29, 2019

Reproduction

StackBlitz: https://stackblitz.com/edit/components-issue-bde981

Steps to reproduce:

  1. Click on the Doesn't Work button to open the dialog
  2. Hit enter

Expected Behavior

In the working example hitting enter submits the form and in this case, closes the dialog. I wouldn't expect that adding
the MatDialogClose directive in place of the click method would change that.

Actual Behavior

Adding MatDialogClose prevents the form from being submitted when hitting enter and not having the button focused.

Environment

  • Angular: 8.0.0
  • CDK/Material: 8.0.0
  • Browser(s): Chrome 76.0
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows
@tomicarsk6
Copy link
Contributor

More about the reason behind that you can see here #2599.

@flauc
Copy link
Contributor Author

flauc commented Aug 29, 2019

I don't understand why it would override type=submit if already defined on the element though.

@tomicarsk6
Copy link
Contributor

I agree with you, that is something that needs to be supported, if you don't define button type then it should work like it's working, but if you define it then this value should be used instead.

@jelbourn jelbourn added the P5 The team acknowledges the request but does not plan to address it, it remains open for discussion label Aug 30, 2019
@jelbourn
Copy link
Member

Agreed that it shouldn't change the type if it's set manually. As a workaround, you can add a submit button that calls dialogRef.close()

@jelbourn jelbourn added the help wanted The team would appreciate a PR from the community to address this issue label Aug 30, 2019
flauc added a commit to flauc/components that referenced this issue Aug 30, 2019
only default the type attribute on mat-dialog-close if it isn't set

angular#16909
flauc added a commit to flauc/components that referenced this issue Aug 31, 2019
jelbourn pushed a commit that referenced this issue Sep 6, 2019
only default the type attribute on mat-dialog-close if it isn't set

#16909
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted The team would appreciate a PR from the community to address this issue P5 The team acknowledges the request but does not plan to address it, it remains open for discussion
Projects
None yet
Development

No branches or pull requests

4 participants