Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sheets-ui): resolve issue where hidden worksheets cannot be unhidden #2258

Merged
merged 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading