Components: How to prevent mat-menu to submit form?

Created on 13 Mar 2018  路  2Comments  路  Source: angular/components

Bug, feature request, or proposal:

I used mat-menu in a <form>. When I clicked the mat-menu button, it triggered the mat-menu, but also triggered the form submit.

What is the expected behavior?

It should only trigger the mat-menu, and don't trigger the form submit.

What is the current behavior?

It triggered the mat-menu, and also triggered the form submit.

What is the use-case or motivation for changing an existing behavior?

I was not used mat-menu for menu. I used mat-menu in a form control for user to quick select some items into the text field.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular CLI: 1.7.2
Node: 8.4.0
OS: darwin x64
Angular: 5.2.0
... animations, cdk, common, compiler, compiler-cli, core, forms
... http, language-service, material, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.7.2
@angular/flex-layout: 2.0.0-beta.12
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.1
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.5.3
webpack: 3.11.0

Most helpful comment

I resolved it.
I add type="button" to mat-menu button.

All 2 comments

I resolved it.
I add type="button" to mat-menu button.

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._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jelbourn picture jelbourn  路  3Comments

alanpurple picture alanpurple  路  3Comments

Miiekeee picture Miiekeee  路  3Comments

dzrust picture dzrust  路  3Comments

shlomiassaf picture shlomiassaf  路  3Comments