From 82d7f940091236f8e4f05481c3adc42a86f3900f Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Thu, 26 May 2022 22:57:19 +0300 Subject: [PATCH] RED-4018 -> checked if the event is fired from mat dialog container on enter for the save method to not be called twice in case it's fired from input element --- src/lib/dialog/base-dialog.component.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/dialog/base-dialog.component.ts b/src/lib/dialog/base-dialog.component.ts index 33b8f4a..bfa554d 100644 --- a/src/lib/dialog/base-dialog.component.ts +++ b/src/lib/dialog/base-dialog.component.ts @@ -6,6 +6,8 @@ import { ConfirmOptions } from '../misc'; import { ConfirmationDialogService } from './confirmation-dialog.service'; import { firstValueFrom } from 'rxjs'; +const TARGET_NODE = 'mat-dialog-container'; + export interface SaveOptions { closeAfterSave?: boolean; addMembers?: boolean; @@ -75,8 +77,8 @@ export abstract class BaseDialogComponent extends AutoUnsubscribe implements OnI @HostListener('window:keydown.Enter', ['$event']) onEnter(event: KeyboardEvent): void { event?.stopImmediatePropagation(); - const node = (event.target as IqserEventTarget).localName; - if (this.valid && !this.disabled && this.changed && node !== 'textarea') { + const node = (event.target as IqserEventTarget).localName?.trim()?.toLowerCase(); + if (this.valid && !this.disabled && this.changed && node === TARGET_NODE) { this.save(); } }