@firestitch/form 13.3.4 → 13.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -483,21 +483,28 @@ class FsFormDirective {
483
483
  }
484
484
  });
485
485
  }
486
+ _activeDialog(el, dialog) {
487
+ if (el.isSameNode(dialog)) {
488
+ return true;
489
+ }
490
+ else if (el.parentElement) {
491
+ return this._activeDialog(el.parentElement, dialog);
492
+ }
493
+ return false;
494
+ }
486
495
  _listenHotKeys() {
487
496
  this._ngZone.runOutsideAngular(() => {
488
497
  fromEvent(document, 'keydown')
489
498
  .pipe(takeUntil(this._destroy$))
490
499
  .subscribe((event) => {
491
500
  if (this._dialogBackdropEscape && event.code === 'Escape') {
492
- const dialog = document.getElementById(this._dialogRef.id);
493
- const paths = event.composedPath();
494
- if (paths) {
495
- paths.forEach((item) => {
496
- if (dialog === item) {
497
- this._ngZone.run(() => {
498
- this._formClose();
499
- });
500
- }
501
+ const cdkOverlayPane = Array
502
+ .from(document.querySelectorAll('.cdk-overlay-pane')).pop();
503
+ const activeDialog = this
504
+ ._activeDialog(document.getElementById(this._dialogRef.id), cdkOverlayPane);
505
+ if (activeDialog) {
506
+ this._ngZone.run(() => {
507
+ this._formClose();
501
508
  });
502
509
  }
503
510
  }