RED-6960 - Enter should always confirm a modal window
This commit is contained in:
parent
63df71a6aa
commit
8ba271bb6c
@ -1,7 +1,7 @@
|
||||
import { Directive, HostListener, inject } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { hasFormChanged, IqserEventTarget } from '../utils';
|
||||
import { hasFormChanged } from '../utils';
|
||||
import { FormGroup } from '@angular/forms';
|
||||
|
||||
const DATA_TYPE_SYMBOL = Symbol.for('DATA_TYPE');
|
||||
@ -10,7 +10,6 @@ const RETURN_TYPE_SYMBOL = Symbol.for('RETURN_TYPE');
|
||||
export type DATA_TYPE = typeof DATA_TYPE_SYMBOL;
|
||||
export type RETURN_TYPE = typeof RETURN_TYPE_SYMBOL;
|
||||
|
||||
const TARGET_NODE = 'mat-dialog-container';
|
||||
|
||||
@Directive()
|
||||
export abstract class IqserDialogComponent<ComponentType, DataType, ReturnType> {
|
||||
@ -53,8 +52,7 @@ export abstract class IqserDialogComponent<ComponentType, DataType, ReturnType>
|
||||
@HostListener('window:keydown.Enter', ['$event'])
|
||||
onEnter(event: KeyboardEvent): void {
|
||||
event?.stopImmediatePropagation();
|
||||
const node = (event.target as IqserEventTarget).localName?.trim()?.toLowerCase();
|
||||
if (this.onEnterValidator(event) && node === TARGET_NODE) {
|
||||
if (this.onEnterValidator(event)) {
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user