diff --git a/frontend/src/app/shared/components/fields/edit/field/editable-attribute-field.component.ts b/frontend/src/app/shared/components/fields/edit/field/editable-attribute-field.component.ts index e1382bc5143..2f72c61ea8d 100644 --- a/frontend/src/app/shared/components/fields/edit/field/editable-attribute-field.component.ts +++ b/frontend/src/app/shared/components/fields/edit/field/editable-attribute-field.component.ts @@ -90,6 +90,24 @@ export class EditableAttributeFieldComponent extends UntilDestroyedMixin impleme public destroyed = false; public setActive(active = true):void { + if (active && !this.active) { + // When switching to edit mode, the display container collapses immediately + // (display:none) while the edit portal renders asynchronously. This shrinks + // the page height and the browser clamps scroll to the new maximum, causing + // the page to jump to the bottom. Preserve the wrapper height to prevent this. + // Note: min-height must be set on the block wrapper div, not the host element + // (op-editable-attribute-field is display:inline and ignores min-height). + const wrapperEl = this.displayContainer.nativeElement.parentElement; + const height = this.displayContainer.nativeElement.offsetHeight; + if (wrapperEl && height > 0) { + wrapperEl.style.minHeight = `${height}px`; + } + } else if (!active) { + const wrapperEl = this.displayContainer.nativeElement.parentElement; + if (wrapperEl) { + wrapperEl.style.minHeight = ''; + } + } this.active = active; if (!this.componentDestroyed) { this.cdRef.detectChanges(); @@ -226,4 +244,3 @@ export class EditableAttributeFieldComponent extends UntilDestroyedMixin impleme return this.schemaCache.of(this.resource); } } -