Skip to content

Commit

Permalink
fix(sheets-ui): resolve issue where hidden worksheets cannot be unhid…
Browse files Browse the repository at this point in the history
…den (#2258)
  • Loading branch information
jikkai committed May 16, 2024
1 parent 91e6fbc commit 5e02b6e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -28,23 +28,26 @@ import {
import { getSheetCommandTarget } from './utils/target-util';

export interface ISetWorksheetShowCommandParams {
unitId: string;
subUnitId: string;
value?: string;
}

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);

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;
Expand Down

0 comments on commit 5e02b6e

Please sign in to comment.