@klippa/ngx-enhancy-forms 14.22.6 → 14.22.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/form/form-element/form-element.component.mjs +16 -7
- package/fesm2015/klippa-ngx-enhancy-forms.mjs +15 -7
- package/fesm2015/klippa-ngx-enhancy-forms.mjs.map +1 -1
- package/fesm2020/klippa-ngx-enhancy-forms.mjs +15 -6
- package/fesm2020/klippa-ngx-enhancy-forms.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -668,10 +668,11 @@ class FormElementComponent {
|
|
|
668
668
|
return this.getErrorToShow() === error && !this.customErrorHandlers.some((e) => e.error === error);
|
|
669
669
|
}
|
|
670
670
|
getScrollableParent(node) {
|
|
671
|
-
if (node
|
|
672
|
-
return
|
|
671
|
+
if (node === window.document.documentElement) {
|
|
672
|
+
return window.document.documentElement;
|
|
673
673
|
}
|
|
674
|
-
|
|
674
|
+
const overflowY = getComputedStyle(node).overflowY;
|
|
675
|
+
if (node.clientHeight < node.scrollHeight && (overflowY === 'auto' || overflowY === 'scroll')) {
|
|
675
676
|
return node;
|
|
676
677
|
}
|
|
677
678
|
else {
|
|
@@ -679,9 +680,17 @@ class FormElementComponent {
|
|
|
679
680
|
}
|
|
680
681
|
}
|
|
681
682
|
scrollTo() {
|
|
682
|
-
this.internalComponentRef.nativeElement
|
|
683
|
-
|
|
684
|
-
this.
|
|
683
|
+
const parent = this.getScrollableParent(this.internalComponentRef.nativeElement);
|
|
684
|
+
const parentTop = parent === window.document.documentElement ? 0 : parent.getBoundingClientRect().top;
|
|
685
|
+
const elementTop = this.internalComponentRef.nativeElement.getBoundingClientRect().top;
|
|
686
|
+
const parentScrollTop = parent.scrollTop;
|
|
687
|
+
const answer = elementTop - parentTop + parentScrollTop;
|
|
688
|
+
console.log('answer', parentTop, elementTop, parentScrollTop, answer);
|
|
689
|
+
console.log(parent, this.internalComponentRef.nativeElement);
|
|
690
|
+
parent.scrollTo({
|
|
691
|
+
top: answer - 30,
|
|
692
|
+
behavior: 'smooth'
|
|
693
|
+
});
|
|
685
694
|
}
|
|
686
695
|
isRequired() {
|
|
687
696
|
if (isValueSet(this.input)) {
|