From 7e4e51f82c0b6748ab1b791139c73f934120694e Mon Sep 17 00:00:00 2001 From: George Date: Wed, 12 Apr 2023 18:08:58 +0300 Subject: [PATCH] Fix thrown error in edit modals. --- src/lib/dialog/base-dialog.component.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/dialog/base-dialog.component.ts b/src/lib/dialog/base-dialog.component.ts index 00d88b6..ceb8a2c 100644 --- a/src/lib/dialog/base-dialog.component.ts +++ b/src/lib/dialog/base-dialog.component.ts @@ -1,4 +1,4 @@ -import { Directive, HostListener, inject, OnDestroy, OnInit } from '@angular/core'; +import { AfterViewInit, Directive, HostListener, inject, OnDestroy, OnInit } from '@angular/core'; import { MatDialog, MatDialogRef } from '@angular/material/dialog'; import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; import { hasFormChanged, IqserEventTarget } from '../utils'; @@ -18,7 +18,7 @@ export interface SaveOptions { } @Directive() -export abstract class BaseDialogComponent implements OnInit, OnDestroy { +export abstract class BaseDialogComponent implements AfterViewInit, OnDestroy { readonly iconButtonTypes = IconButtonTypes; form?: UntypedFormGroup; initialFormValue!: Record; @@ -44,7 +44,7 @@ export abstract class BaseDialogComponent implements OnInit, OnDestroy { return !this.valid || !this.changed || this.#hasErrors; } - ngOnInit() { + ngAfterViewInit() { this.#subscriptions.add(this._dialogRef.backdropClick().subscribe(() => this.close())); const events = [fromEvent(window, 'keyup'), fromEvent(window, 'input'), this.form?.valueChanges];