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): row height no ranges (#4629)

Dushusiraee23ec9f5f3
diff --git a/e2e/visual-comparison/sheets/sheets-switching-render-unit.spec.ts b/e2e/visual-comparison/sheets/sheets-switching-render-unit.spec.ts
index e0561fdda9..91feb1bf9f 100644
--- a/e2e/visual-comparison/sheets/sheets-switching-render-unit.spec.ts
+++ b/e2e/visual-comparison/sheets/sheets-switching-render-unit.spec.ts
@@ -36,6 +36,8 @@ test('ensure switching render unit successful with no errors', async () => {
await page.waitForTimeout(1000);
await page.evaluate(() => window.E2EControllerAPI.loadDefaultSheet());
+ await page.waitForTimeout(1000);
+
const filename = generateSnapshotName('switching-render-unit');
const firstScreenshot = await page.screenshot({
mask: [
diff --git a/packages/sheets-ui/src/facade/f-univer.ts b/packages/sheets-ui/src/facade/f-univer.ts
index 38e33336bc..2e3e672e7e 100644
--- a/packages/sheets-ui/src/facade/f-univer.ts
+++ b/packages/sheets-ui/src/facade/f-univer.ts
@@ -708,7 +708,7 @@ export class FUniverSheetsUIMixin extends FUniver implements IFUniverSheetsUIMix
if (COMMAND_LISTENER_SKELETON_CHANGE.indexOf(commandInfo.id) > -1) {
const sheet = this.getActiveSheet();
if (!sheet) return;
- const ranges = getSkeletonChangedEffectedRange(commandInfo)
+ const ranges = getSkeletonChangedEffectedRange(commandInfo, sheet.worksheet.getMaxColumns())
.map((range) => this.getWorkbook(range.unitId)?.getSheetBySheetId(range.subUnitId)?.getRange(range.range))
.filter(Boolean) as FRange[];
if (!ranges.length) return;
diff --git a/packages/sheets/src/basics/const/command-listener-const.ts b/packages/sheets/src/basics/const/command-listener-const.ts
index 68ae01a0ad..fd438f4900 100644
--- a/packages/sheets/src/basics/const/command-listener-const.ts
+++ b/packages/sheets/src/basics/const/command-listener-const.ts
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+import type { ICommandInfo, IRange } from '@univerjs/core';
import type { IMoveRangeMutationParams } from '../../commands/mutations/move-range.mutation';
import type { IMoveColumnsMutationParams, IMoveRowsMutationParams } from '../../commands/mutations/move-rows-cols.mutation';
import type { IReorderRangeMutationParams } from '../../commands/mutations/reorder-range.mutation';
@@ -32,7 +33,7 @@ import type {
import type { IToggleGridlinesMutationParams } from '../../commands/mutations/toggle-gridlines.mutation';
import type { ISetWorksheetActiveOperationParams } from '../../commands/operations/set-worksheet-active.operation';
import type { IAddWorksheetMergeMutationParams, IInsertColMutationParams, IInsertRowMutationParams, IRemoveColMutationParams, IRemoveRowsMutationParams, IRemoveWorksheetMergeMutationParams, IWorksheetRangeThemeStyleMutationParams } from '../interfaces';
-import { type ICommandInfo, type IRange, ObjectMatrix, RANGE_TYPE } from '@univerjs/core';
+import { ObjectMatrix, RANGE_TYPE } from '@univerjs/core';
import { AddWorksheetMergeMutation } from '../../commands/mutations/add-worksheet-merge.mutation';
import { SetWorksheetRangeThemeStyleMutation } from '../../commands/mutations/add-worksheet-range-theme.mutation';
import { DeleteWorksheetRangeThemeStyleMutation } from '../../commands/mutations/delete-worksheet-range-theme.mutation';
@@ -362,11 +363,10 @@ export function getValueChangedEffectedRange(commandInfo: ICommandInfo): { unitI
* @returns {{ unitId: string; subUnitId: string; range: IRange }[]} Array of affected ranges
*/
// eslint-disable-next-line max-lines-per-function
-export function getSkeletonChangedEffectedRange(commandInfo: ICommandInfo): { unitId: string; subUnitId: string; range: IRange }[] {
+export function getSkeletonChangedEffectedRange(commandInfo: ICommandInfo, columnCount: number): { unitId: string; subUnitId: string; range: IRange }[] {
switch (commandInfo.id) {
case SheetSkeletonChangeType.SET_WORKSHEET_ROW_HEIGHT:
- case SheetSkeletonChangeType.SET_WORKSHEET_ROW_IS_AUTO_HEIGHT:
- case SheetSkeletonChangeType.SET_WORKSHEET_ROW_AUTO_HEIGHT: {
+ case SheetSkeletonChangeType.SET_WORKSHEET_ROW_IS_AUTO_HEIGHT: {
const params = commandInfo.params as ISetWorksheetRowHeightMutationParams;
return params.ranges.map((range) => ({
unitId: params.unitId,
@@ -377,6 +377,21 @@ export function getSkeletonChangedEffectedRange(commandInfo: ICommandInfo): { un
},
}));
}
+ // Note: SET_WORKSHEET_ROW_AUTO_HEIGHT has no ranges
+ case SheetSkeletonChangeType.SET_WORKSHEET_ROW_AUTO_HEIGHT:{
+ const params = commandInfo.params as ISetWorksheetRowAutoHeightMutationParams;
+ return params.rowsAutoHeightInfo.map((rowAutoHeightInfo) => ({
+ unitId: params.unitId,
+ subUnitId: params.subUnitId,
+ range: {
+ startRow: rowAutoHeightInfo.row,
+ endRow: rowAutoHeightInfo.row,
+ startColumn: 0,
+ endColumn: columnCount - 1,
+ rangeType: RANGE_TYPE.ROW,
+ },
+ }));
+ }
case SheetSkeletonChangeType.SET_WORKSHEET_COL_WIDTH: {
const params = commandInfo.params as ISetWorksheetColWidthMutationParams;