Skip to content

Commit

Permalink
Fix table row-recalculation on panel switch
Browse files Browse the repository at this point in the history
  • Loading branch information
johannes-wolf committed Aug 23, 2024
1 parent 12af92f commit b973613
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions erdblick_app/app/feature.panel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {MapService} from "./map.service";
import {distinctUntilChanged} from "rxjs";
import {coreLib} from "./wasm";
import {ClipboardService} from "./clipboard.service";
import {TTScrollableView} from "primeng/treetable";
import {TreeTable} from "primeng/treetable";

interface Column {
field: string;
Expand Down Expand Up @@ -185,8 +185,7 @@ export class FeaturePanelComponent implements OnInit {
filterGeometryEntries = false;
jsonTree = "";

@ViewChild('tt')
table!: TTScrollableView;
@ViewChild('tt') table!: TreeTable;

@ViewChild('inspectionMenu') inspectionMenu!: Menu;
inspectionMenuItems: MenuItem[] | undefined;
Expand All @@ -206,7 +205,14 @@ export class FeaturePanelComponent implements OnInit {
});

this.inspectionService.inspectionPanelChanged.subscribe(() => {
this.table.scroller!.calculateOptions();
// We have to force recalculate the tables number of visible items
setTimeout(() => {
let scroller = (<any>this.table.scrollableViewChild)?.scroller;
if (scroller) {
scroller.init();
scroller.calculateAutoSize();
}
}, 0);
})
}

Expand Down
4 changes: 2 additions & 2 deletions erdblick_app/app/inspection.panel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class InspectionPanelComponent implements OnInit
if (index < 0)
index = this.tabs.length - 1;
this.inspectionService.inspectionPanelChanged.emit();
this.activeIndex = index
this.activeIndex = Math.max(0, index)
}

onGoBack(event: any) {
Expand All @@ -145,7 +145,7 @@ export class InspectionPanelComponent implements OnInit
const onClose = this.tabs[this.activeIndex]['onClose'];
if (onClose)
onClose();
this.activeIndex = this.activeIndex - 1;
this.setTab(this.activeIndex - 1);
if (this.tabs.length > 1)
this.tabs.pop();
}
Expand Down

0 comments on commit b973613

Please sign in to comment.