question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug(MatButtonModule): Disabled mat-button with routerLink still works

See original GitHub issue

Reproduction

The issue is reproduced on StackBlitz: https://stackblitz.com/edit/inactive-links-problem

Steps to reproduce:

  1. 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:open
  • Created 3 years ago
  • Reactions:3
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
scopchanovcommented, May 27, 2020

I hope the following info could help fixing the issue:

  1. It does work with the original example from Angular Material + added [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 href instead of routerLink.

  1. It also works as expected with MatListItem, i.e.
<mat-nav-list>
    <a mat-list-item routerLink="/foo" [disabled]="true">Foo</a>
    <a mat-list-item routerLink="/moo" [disabled]="true">Moo</a>
</mat-nav-list>
  1. Only the combination of mat-button and routerLink does not work well with disabled.

Could MatListItem be used as an example to fix MatButton?

0reactions
filarrrocommented, Jan 17, 2021

+1 on this one, if the attribute is supported then it should be working as expected

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found