fix(viewboxes): hot v16 fails to load because of relative height 100% #183

Merged
mihajlo merged 1 commits from hot16-viewboxes into main 2025-07-24 11:29:34 +00:00
2 changed files with 51 additions and 2 deletions

View File

@@ -401,7 +401,7 @@
[columns]="viewboxTables[viewboxTableIndex].hotTable.columns" [columns]="viewboxTables[viewboxTableIndex].hotTable.columns"
[filters]="true" [filters]="true"
[dropdownMenu]="viewboxTables[viewboxTableIndex].hotTable.dropdownMenu" [dropdownMenu]="viewboxTables[viewboxTableIndex].hotTable.dropdownMenu"
[height]="viewboxTables[viewboxTableIndex].hotTable.height" [height]="calculateTableHeight(viewbox)"
stretchH="all" stretchH="all"
[cells]="viewboxTables[viewboxTableIndex].hotTable.cells" [cells]="viewboxTables[viewboxTableIndex].hotTable.cells"
[maxRows]="viewboxTables[viewboxTableIndex].hotTable.maxRows" [maxRows]="viewboxTables[viewboxTableIndex].hotTable.maxRows"

View File

@@ -111,7 +111,7 @@ export class ViewboxesComponent implements OnInit, AfterViewInit, OnDestroy {
}, },
columns: [], columns: [],
cols: [], cols: [],
height: '100%', height: 200, //WORKAROUND: Changed from '100%' to fixed pixel value because otherwize hot does not load
settings: {}, settings: {},
hiddenColumns: true, hiddenColumns: true,
manualColumnMove: false, manualColumnMove: false,
@@ -513,6 +513,11 @@ export class ViewboxesComponent implements OnInit, AfterViewInit, OnDestroy {
this.helperService.debounceCall(1000, () => { this.helperService.debounceCall(1000, () => {
this.viewboxChanged() this.viewboxChanged()
this.eventService.dispatchEvent('resize') this.eventService.dispatchEvent('resize')
// Refresh all viewbox tables after resize
this.viewboxes.forEach((viewbox) => {
this.refreshTableAfterResize(viewbox)
})
}) })
return { return {
@@ -672,6 +677,11 @@ export class ViewboxesComponent implements OnInit, AfterViewInit, OnDestroy {
setTimeout(() => { setTimeout(() => {
this.setAllHandleTransform() this.setAllHandleTransform()
// Refresh all tables after snap to grid
this.viewboxes.forEach((viewbox) => {
this.refreshTableAfterResize(viewbox)
})
}) })
} }
@@ -713,6 +723,11 @@ export class ViewboxesComponent implements OnInit, AfterViewInit, OnDestroy {
viewbox.minimized = false viewbox.minimized = false
this.viewboxChanged() this.viewboxChanged()
// Refresh table after restoring
setTimeout(() => {
this.refreshTableAfterResize(viewbox)
}, 100)
} }
collapse(viewbox: Viewbox) { collapse(viewbox: Viewbox) {
@@ -723,6 +738,11 @@ export class ViewboxesComponent implements OnInit, AfterViewInit, OnDestroy {
expand(viewbox: Viewbox) { expand(viewbox: Viewbox) {
viewbox.collapsed = false viewbox.collapsed = false
this.viewboxChanged() this.viewboxChanged()
// Refresh table after expanding
setTimeout(() => {
this.refreshTableAfterResize(viewbox)
}, 100)
} }
/** /**
@@ -1158,6 +1178,35 @@ export class ViewboxesComponent implements OnInit, AfterViewInit, OnDestroy {
} }
} }
/**
* WORKAROUND: This is a workaround to calculate the height of the table since `100%`
* makes hot not load
* Calculate available height for Handsontable
* @param viewbox The viewbox to calculate height for
* @returns Available height in pixels
*/
calculateTableHeight(viewbox: Viewbox): number {
// Calculate the exact height of the content div
const dragHandleHeight = 20
const searchFormHeight = 38
// Return the exact remaining height for the table
return viewbox.height - dragHandleHeight - searchFormHeight
}
/**
* Refresh Handsontable instance after resize
* @param viewbox The viewbox to refresh
*/
refreshTableAfterResize(viewbox: Viewbox): void {
const hotInstance = this.getViewboxHotInstance(viewbox.id)
if (hotInstance) {
// Force the table to recalculate its dimensions
setTimeout(() => {
hotInstance.refreshDimensions()
}, 100)
}
}
/** /**
* *
* @param viewboxId * @param viewboxId