Fix thrown error in edit modals.

This commit is contained in:
George 2023-04-12 18:08:58 +03:00
parent b57998fcb4
commit 7e4e51f82c

View File

@ -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<string, string>;
@ -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];