Skip to content

Commit

Permalink
optimize formElement scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
wouter-willems committed Oct 7, 2024
1 parent 1b8aa7c commit f261bd1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion projects/klippa/ngx-enhancy-forms/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@klippa/ngx-enhancy-forms",
"version": "18.23.7",
"version": "18.23.8",
"publishConfig": {
"access": "public"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
ElementRef,
Inject,
InjectionToken,
Input, OnDestroy,
Input, NgZone, OnDestroy,
Optional,
TemplateRef,
ViewChild
Expand Down Expand Up @@ -69,6 +69,7 @@ export class FormElementComponent implements AfterViewInit, OnDestroy {
@Optional() private parent: FormComponent,
@Inject(FORM_ERROR_MESSAGES) @Optional() private customMessages: CustomErrorMessages,
private elRef: ElementRef,
private ngZone: NgZone,
) {
}

Expand Down Expand Up @@ -123,15 +124,17 @@ export class FormElementComponent implements AfterViewInit, OnDestroy {
return;
}
const containers = [...getAllLimitingContainers(this.elRef.nativeElement), window];
if (current === 'lockedOpen') {
containers.forEach(e => {
e.addEventListener('scroll', this.setErrorTooltipOffset);
});
} else {
containers.forEach(e => {
e.removeEventListener('scroll', this.setErrorTooltipOffset);
});
}
this.ngZone.runOutsideAngular(() => {
if (current === 'lockedOpen') {
containers.forEach(e => {
e.addEventListener('scroll', this.setErrorTooltipOffset);
});
} else {
containers.forEach(e => {
e.removeEventListener('scroll', this.setErrorTooltipOffset);
});
}
});
}

public unregisterControl(formControl: UntypedFormControl): void {
Expand Down

0 comments on commit f261bd1

Please sign in to comment.