Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix(sheets-ui): dynamically adjust row header width (#1475)

Wenzhao Hu371b4f13a07b
diff --git a/packages/engine-render/src/components/sheets/sheet-skeleton.ts b/packages/engine-render/src/components/sheets/sheet-skeleton.ts
index 9243a13ef5..b4dd150e2d 100644
--- a/packages/engine-render/src/components/sheets/sheet-skeleton.ts
+++ b/packages/engine-render/src/components/sheets/sheet-skeleton.ts
@@ -524,7 +524,7 @@ export class SpreadsheetSkeleton extends Skeleton {
defaultColumnWidth
);
- this._rowHeaderWidth = rowHeader.hidden !== BooleanNumber.TRUE ? rowHeader.width : 0;
+ this._rowHeaderWidth = rowHeader.hidden !== BooleanNumber.TRUE ? this._dynamicallyUpdateRowHeaderWidth(rowHeader) : 0;
this._columnHeaderHeight = columnHeader.hidden !== BooleanNumber.TRUE ? columnHeader.height : 0;
this._rowTotalHeight = rowTotalHeight;
@@ -538,10 +538,11 @@ export class SpreadsheetSkeleton extends Skeleton {
return this;
}
- // updateDataMerge() {
- // const { mergeData } = this._config;
- // this._dataMergeCacheAll = mergeData && this._getMergeCells(mergeData);
- // }
+ private _dynamicallyUpdateRowHeaderWidth(rowHeader: { width: number }): number {
+ const SIZE_BY_EACH_CHARACTER = 8;
+ const widthByComputation = (`${this._worksheet?.getRowCount()}`.length * SIZE_BY_EACH_CHARACTER);
+ return Math.max(rowHeader.width, widthByComputation);
+ }
getRowColumnSegment(bounds?: IViewportBound) {
return this._getBounding(this._rowHeightAccumulation, this._columnWidthAccumulation, bounds?.viewBound);