One of the challenges I encountered is with a directive called [appInvalidField] that functions like a custom tooltip for validation purposes. To ensure it appears above everything else within dialogs, I attach it to the body and position it near the relevant field.
The issue arises when scrolling comes into play. I realized that I need to dynamically adjust the tooltip's position based on scroll events triggered by the form. The tricky part is figuring out how to achieve this adjustment within the directive file without altering the existing HTML structure. Below is an example of how the directive is used in a form:
<form #ngForm="ngForm" [formGroup]="form" (ngSubmit)="onSave()">
<div class="form--edit">
<div class="form__group p-grid">
<label class="p-col-12 form__label">{{'substance.IUPACName-title' | translate}}</label>
<div appInvalidField="names">
<span *appInvalidFieldType="'required'" [translate]="'substance.IUPACName-field-required'"></span>
<span *appInvalidFieldType="'maxlength'"
[translate]="'substance.IUPACName-field-maxlength'"></span>
</div>
<input class="p-col" pInputText [maxLength]="formService.maxLength" appAutofocus formControlName="names" />
</div>
</div>
</form>