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(sheet): fix auto heigt cause some code error (#4705)

VicKun568f8bc0697c
diff --git a/packages/sheets-ui/src/controllers/auto-height.controller.ts b/packages/sheets-ui/src/controllers/auto-height.controller.ts
index b734820bb3..134b492102 100644
--- a/packages/sheets-ui/src/controllers/auto-height.controller.ts
+++ b/packages/sheets-ui/src/controllers/auto-height.controller.ts
@@ -81,8 +81,18 @@ export class AutoHeightController extends Disposable {
};
}
const config = configService.getConfig<IUniverSheetsUIConfig>(SHEETS_UI_PLUGIN_CONFIG_KEY);
- const count = this._getRangesScope(ranges);
- if (config?.maxAutoHeightCount! < count) {
+ let rangeList = ranges;
+ if (!Array.isArray(ranges)) {
+ // The code "const params = command.params as ISetRangeValuesRangeMutationParams;" of _initialize() method may make IRange as IRange[]. so need adjust here.
+ if ((ranges as IRange).startRow !== undefined && (ranges as IRange).startRow !== undefined) {
+ rangeList = [ranges];
+ } else {
+ rangeList = [];
+ }
+ }
+ const count = this._getRangesScope(rangeList);
+ const maxLimit = config?.maxAutoHeightCount ?? 1000;
+ if (maxLimit < count) {
return {
redos: [],
undos: [],