From 47fec83ae1c95fc918e27e422e0d406aae253734 Mon Sep 17 00:00:00 2001 From: Fahri Gedik Date: Mon, 17 Nov 2025 11:09:07 +0300 Subject: [PATCH] Simplify initial field focus logic in form prop component Replaces the IntersectionObserver-based focus logic with a simpler requestAnimationFrame approach for focusing the first field. This reduces complexity and potential timing issues when focusing the field after view initialization. --- .../extensible-form-prop.component.ts | 29 ++----------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/npm/ng-packs/packages/components/extensible/src/lib/components/extensible-form/extensible-form-prop.component.ts b/npm/ng-packs/packages/components/extensible/src/lib/components/extensible-form/extensible-form-prop.component.ts index 6599647f61..ca567d0511 100644 --- a/npm/ng-packs/packages/components/extensible/src/lib/components/extensible-form/extensible-form-prop.component.ts +++ b/npm/ng-packs/packages/components/extensible/src/lib/components/extensible-form/extensible-form-prop.component.ts @@ -155,33 +155,10 @@ export class ExtensibleFormPropComponent implements OnChanges, AfterViewInit { ngAfterViewInit() { if (this.isFirstGroup && this.first && this.fieldRef) { - this.focusField(); - } - } - - private focusField() { - const element = this.fieldRef.nativeElement; - - if (this.isElementVisible(element)) { - element.focus(); - return; - } - - const observer = new IntersectionObserver((entries) => { - entries.forEach(entry => { - if (entry.isIntersecting && entry.intersectionRatio > 0) { - element.focus(); - observer.disconnect(); - } + requestAnimationFrame(() => { + this.fieldRef.nativeElement.focus(); }); - }, { threshold: 0.01 }); - - observer.observe(element); - setTimeout(() => observer.disconnect(), 5000); - } - - private isElementVisible(element: HTMLElement): boolean { - return element.offsetParent !== null; + } } getComponent(prop: FormProp): string {