bug(MatButtonModule): Disabled mat-button with routerLink still works
See original GitHub issueReproduction
The issue is reproduced on StackBlitz: https://stackblitz.com/edit/inactive-links-problem
Steps to reproduce:
- Use the following code:
<a mat-button routerLink="/foo" [disabled]="true">Foo</a>
Expected Behavior
The button is visually disabled and clicking it does not activate the link.
Actual Behavior
The button is indeed visually disabled, but the link still works.
Environment
- Angular: 9.1.9
- CDK/Material: 9.2.4
- Browser(s): Chrome, Mozilla, Safari
- Operating System (e.g. Windows, macOS, Ubuntu): Windows, iOS
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Why does a disabled RouterLink still work? - Stack Overflow
I have a problem with links, which are active, although their disabled attribute is set to true . Setup. Following this pattern from...
Read more >Angular Material Buttons : Mat-Button Example - Angular Wiki
Angular Material button module MatButtonModule(mat-button,mat-raised-button,mat-icon-button,mat-fab,mat-mini-fab) enhances the user ...
Read more >Build a CRUD-y SPA with Node and Angular - Okta Developer
This tutorial walks you through building a simple CRUD application in Node and Angular 6.
Read more >Learn about Angular Material Design Buttons - Morioh
<button mat-button color=“warn”>Warn</button> <button mat-button disabled>Disabled</button> <a mat-button routerLink=“.”>Link</a> ...
Read more >can't bind to 'mat-dialog-close' since it isn't a known property of ...
Bug, feature request, or proposal: Hi, I'm trying to work with a tutorial about modal in angular 5 -> https://material.angular.io/components/dialog/overview ...
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

I hope the following info could help fixing the issue:
[disabled]="true", i.e.<a mat-button href="https://www.google.com/" target="_blank" [disabled]="true">Link</a>However, in this case the attribute is
hrefinstead ofrouterLink.MatListItem, i.e.mat-buttonandrouterLinkdoes not work well withdisabled.Could
MatListItembe used as an example to fixMatButton?+1 on this one, if the attribute is supported then it should be working as expected