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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(sheets-ui): resolve issue where hidden worksheets cannot be unhidden (#2258)
白熱5e02b6ece21c
diff --git a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-menu/SheetBarMenu.tsx b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-menu/SheetBarMenu.tsxindex f3e24b1dbd..e72e3d117d 100644--- a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-menu/SheetBarMenu.tsx+++ b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-menu/SheetBarMenu.tsx@@ -65,6 +65,8 @@ export function SheetBarMenu(props: ISheetBarMenuProps) {if (item.hidden) {commandService.executeCommand(SetWorksheetShowCommand.id, {+ unitId: workbook.getUnitId(),+ subUnitId: sheetId,value: sheetId,});} else if (!item.selected) {diff --git a/packages/sheets/src/commands/commands/set-worksheet-show.command.ts b/packages/sheets/src/commands/commands/set-worksheet-show.command.tsindex 6aa6f82ce5..8d68239e0d 100644--- a/packages/sheets/src/commands/commands/set-worksheet-show.command.ts+++ b/packages/sheets/src/commands/commands/set-worksheet-show.command.ts@@ -14,8 +14,8 @@* limitations under the License.*/-import type { ICommand } from '@univerjs/core';-import { BooleanNumber, CommandType, ICommandService, IUndoRedoService, IUniverInstanceService } from '@univerjs/core';+import type { ICommand, Workbook } from '@univerjs/core';+import { BooleanNumber, CommandType, ICommandService, IUndoRedoService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';import type { IAccessor } from '@wendellhu/redi';import type { ISetWorksheetHideMutationParams } from '../mutations/set-worksheet-hide.mutation';@@ -28,6 +28,8 @@ import {import { getSheetCommandTarget } from './utils/target-util';export interface ISetWorksheetShowCommandParams {+ unitId: string;+ subUnitId: string;value?: string;}@@ -35,7 +37,9 @@ export const SetWorksheetShowCommand: ICommand = {type: CommandType.COMMAND,id: 'sheet.command.set-worksheet-show',- handler: async (accessor: IAccessor, params?: ISetWorksheetShowCommandParams) => {+ handler: async (accessor: IAccessor, params: ISetWorksheetShowCommandParams) => {+ const { unitId, subUnitId } = params;+const commandService = accessor.get(ICommandService);const undoRedoService = accessor.get(IUndoRedoService);const univerInstanceService = accessor.get(IUniverInstanceService);@@ -43,8 +47,7 @@ export const SetWorksheetShowCommand: ICommand = {const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));if (!target) return false;- const { unitId, subUnitId } = target;- const workbook = univerInstanceService.getUniverSheetInstance(unitId);+ const workbook = univerInstanceService.getCurrentUnitForType<Workbook>(UniverInstanceType.UNIVER_SHEET)!;if (!workbook) return false;const worksheet = workbook.getSheetBySheetId(subUnitId);if (!worksheet) return false;