Fix event propagation on disabled circle button

This commit is contained in:
Adina Țeudan 2023-01-17 06:18:03 +02:00
parent c91f923bfa
commit f98109ca45
2 changed files with 15 additions and 8 deletions

View File

@ -1,15 +1,20 @@
<div [matTooltipClass]="tooltipClass" [matTooltipPosition]="tooltipPosition" [matTooltip]="tooltip">
<div
(click)="preventActionOnDisabled($event)"
[matTooltipClass]="tooltipClass"
[matTooltipPosition]="tooltipPosition"
[matTooltip]="tooltip"
>
<button
(click)="performAction($event)"
[class.dark-bg]="type === circleButtonTypes.dark"
[class.grey-selected]="greySelected"
[class.help]="type === circleButtonTypes.help"
[class.overlay]="showDot"
[class.primary]="type === circleButtonTypes.primary"
[class.warn]="type === circleButtonTypes.warn"
[class.help]="type === circleButtonTypes.help"
[class.grey-selected]="greySelected"
[disabled]="disabled"
[type]="isSubmit ? 'submit' : 'button'"
[id]="id ? id : buttonId"
[type]="isSubmit ? 'submit' : 'button'"
mat-icon-button
>
<mat-icon [svgIcon]="icon"></mat-icon>

View File

@ -42,10 +42,6 @@ export class CircleButtonComponent implements OnInit {
}
performAction($event: MouseEvent): void {
if (this.disabled) {
return;
}
if (this.removeTooltip) {
this._matTooltip.hide();
// Timeout to allow tooltip to disappear first,
@ -55,4 +51,10 @@ export class CircleButtonComponent implements OnInit {
this.action.emit($event);
}
}
preventActionOnDisabled($event: MouseEvent): void {
if (this.disabled) {
$event.stopPropagation();
}
}
}