From a8490e0439071709e7dc50e54b551eb00605a116 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 22 Feb 2022 08:51:46 +0100 Subject: [PATCH] Fix virtual scroll. --- .../shared/forms/array-editor.component.html | 21 ++++++++++--------- .../shared/forms/array-editor.component.ts | 12 +++++++++++ .../shared/forms/array-item.component.ts | 7 +++++++ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/frontend/src/app/features/content/shared/forms/array-editor.component.html b/frontend/src/app/features/content/shared/forms/array-editor.component.html index 474ebec27..40cd75015 100644 --- a/frontend/src/app/features/content/shared/forms/array-editor.component.html +++ b/frontend/src/app/features/content/shared/forms/array-editor.component.html @@ -1,6 +1,6 @@
-
+ (itemMove)="move(itemForm, $event)" + [language]="language" + [languages]="languages">
- +
+ (itemMove)="move(itemForm, $event)" + [language]="language" + [languages]="languages">
diff --git a/frontend/src/app/features/content/shared/forms/array-editor.component.ts b/frontend/src/app/features/content/shared/forms/array-editor.component.ts index 3fc3050c2..9d515508b 100644 --- a/frontend/src/app/features/content/shared/forms/array-editor.component.ts +++ b/frontend/src/app/features/content/shared/forms/array-editor.component.ts @@ -6,6 +6,7 @@ */ import { CdkDragDrop } from '@angular/cdk/drag-drop'; +import { CdkVirtualScrollViewport } from '@angular/cdk/scrolling'; import { ChangeDetectionStrategy, Component, Input, OnChanges, OnInit, QueryList, SimpleChanges, ViewChildren } from '@angular/core'; import { combineLatest, Observable } from 'rxjs'; import { map } from 'rxjs/operators'; @@ -43,6 +44,9 @@ export class ArrayEditorComponent implements OnChanges, OnInit { @ViewChildren(ArrayItemComponent) public children!: QueryList; + @ViewChildren(CdkVirtualScrollViewport) + public viewport?: QueryList; + public isArray = false; public schemasDropdown = new ModalModel(); @@ -123,6 +127,10 @@ export class ArrayEditorComponent implements OnChanges, OnInit { this.reset(); } + public onExpanded() { + this.viewport?.first?.checkViewportSize(); + } + public collapseAll() { this.children.forEach(child => { child.collapse(); @@ -131,6 +139,8 @@ export class ArrayEditorComponent implements OnChanges, OnInit { if (this.formLevel === 0) { this.localStore.setBoolean(this.expandedKey(), true); } + + this.onExpanded(); } public expandAll() { @@ -141,6 +151,8 @@ export class ArrayEditorComponent implements OnChanges, OnInit { if (this.formLevel === 0) { this.localStore.setBoolean(this.expandedKey(), false); } + + this.onExpanded(); } private reset() { diff --git a/frontend/src/app/features/content/shared/forms/array-item.component.ts b/frontend/src/app/features/content/shared/forms/array-item.component.ts index 21380b9f2..ece2746d5 100644 --- a/frontend/src/app/features/content/shared/forms/array-item.component.ts +++ b/frontend/src/app/features/content/shared/forms/array-item.component.ts @@ -32,6 +32,9 @@ export class ArrayItemComponent extends StatefulComponent implements OnCh @Output() public itemMove = new EventEmitter(); + @Output() + public itemExpanded = new EventEmitter(); + @Output() public clone = new EventEmitter(); @@ -110,10 +113,14 @@ export class ArrayItemComponent extends StatefulComponent implements OnCh public collapse() { this.next({ isExpanded: false }); + + this.itemExpanded.emit(); } public expand() { this.next({ isExpanded: true, isExpandedOnce: true }); + + this.itemExpanded.emit(); } public moveTop() {