components icon indicating copy to clipboard operation
components copied to clipboard

Disabled radio-button still receives click events

Open bagage opened this issue 7 years ago • 5 comments

Reproduction

Use StackBlitz to reproduce your issue: https://stackblitz.com/angular/xxjmayybegr

Steps to reproduce:

  1. Click Disabled button: nothing happens
  2. Click Summer disabled radio button: an alert is emitted.

Expected Behavior

What behavior were you expecting to see?

Since the radio button is disabled, the (click) output should not be emitted.

Actual Behavior

What behavior did you actually see?

The alert is emitted.

Environment

  • Angular: 8.2.9
  • CDK/Material: 8.2.2
  • Browser(s): Chromium Version 77.0.3865.90 (Official Build) Built on Ubuntu , running on Ubuntu 18.04 (64-bit)
  • Operating System (e.g. Windows, macOS, Ubuntu): Debian

bagage avatar Oct 29 '19 14:10 bagage

Doesn't look like the stackblitz has any disabled options

sollenne avatar Oct 30 '19 20:10 sollenne

Damn I failed my stackblitz. Here is the updated URL: https://stackblitz.com/edit/angular-aceywx

bagage avatar Oct 30 '19 20:10 bagage

I think that the issue may be that you directly have the (click) event on the component on your side of your app. Even though the component is disabled, the (click) event will always be emitted, and the material library will not be able to prevent that.

So, the issue in my opinion is not related to the library itself. If you switch to use the (change) event instead of the (click) event, you'll notice that the radio button does not emit when disabled. Any thoughts?

PerezArmando avatar Nov 20 '19 01:11 PerezArmando

The disabled attribute only prevents events on native elements, whereas mat-radio-button is a custom one. You should be able to use the custom change event which won't fire on disabled radio buttons.

crisbeto avatar May 26 '20 15:05 crisbeto

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.