Browse Source

refactor(core): remove markAsDirty loop

pull/2146/head
mehmet-erim 7 years ago
parent
commit
ba9ab6fe29
  1. 19
      npm/ng-packs/packages/core/src/lib/directives/form-submit.directive.ts

19
npm/ng-packs/packages/core/src/lib/directives/form-submit.directive.ts

@ -7,7 +7,7 @@ import {
OnDestroy,
OnInit,
Output,
Self
Self,
} from '@angular/core';
import { FormControl, FormGroup, FormGroupDirective } from '@angular/forms';
import { fromEvent } from 'rxjs';
@ -18,7 +18,7 @@ type Controls = { [key: string]: FormControl } | FormGroup[];
@Directive({
// tslint:disable-next-line: directive-selector
selector: 'form[ngSubmit][formGroup]'
selector: 'form[ngSubmit][formGroup]',
})
export class FormSubmitDirective implements OnInit, OnDestroy {
@Input()
@ -31,7 +31,7 @@ export class FormSubmitDirective implements OnInit, OnDestroy {
constructor(
@Self() private formGroupDirective: FormGroupDirective,
private host: ElementRef<HTMLFormElement>,
private cdRef: ChangeDetectorRef
private cdRef: ChangeDetectorRef,
) {}
ngOnInit() {
@ -44,7 +44,7 @@ export class FormSubmitDirective implements OnInit, OnDestroy {
.pipe(
debounceTime(200),
filter((key: KeyboardEvent) => key && key.key === 'Enter'),
takeUntilDestroy(this)
takeUntilDestroy(this),
)
.subscribe(() => {
if (!this.executedNgSubmit) {
@ -53,17 +53,6 @@ export class FormSubmitDirective implements OnInit, OnDestroy {
this.executedNgSubmit = false;
});
fromEvent(this.host.nativeElement, 'submit')
.pipe(
takeUntilDestroy(this),
filter(() => !this.notValidateOnSubmit && typeof this.notValidateOnSubmit !== 'string')
)
.subscribe(() => {
if (!this.executedNgSubmit) {
this.markAsDirty();
}
});
}
ngOnDestroy(): void {}

Loading…
Cancel
Save