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

This commit is contained in:
Valentin Mihai 2022-05-26 22:57:19 +03:00
parent c8b26771c2
commit 82d7f94009

View File

@ -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();
}
}