Skip to content

mat-button click handlers on anchor tags do not respect the disabled attribute #12920

@daotoad

Description

@daotoad

Bug, feature request, or proposal:

Bug

What is the expected behavior?

Given this template: <a mat-button disabled (click)="someHandler()">Foo</a> the someHandler() method should not be called when the button is clicked.

What is the current behavior?

The someHandler() method is called when the button is clicked.

What are the steps to reproduce?

https://stackblitz.com/edit/angular-ucd9ew

I've included samples with each combination of button/anchor tag and enabled/disabled state.
Clicking the button in each will increment a counter if the handler is called. When clicked, the disabled anchor tag based button in the lower right triggers its handler erroneously.

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

Disabled buttons shouldn't do anything, even when they're made from anchor tags.

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

Only tested with Angular 6.1.6, Material 6.4.7, and TypeScript 2.7.2.
Tested in Chrome for MacOS Version 68.0.3440.106 (Official Build) (64-bit) and in Safari Version 11.1.1 (13605.2.8).

Is there anything else we should know?

Not that I am aware of.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions