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 sheet bar hide menu
jerrya6f079769657
diff --git a/packages/base-sheets/src/Controller/SheetBarController.ts b/packages/base-sheets/src/Controller/SheetBarController.tsindex 116f7163b8..897b1250f3 100644--- a/packages/base-sheets/src/Controller/SheetBarController.ts+++ b/packages/base-sheets/src/Controller/SheetBarController.ts@@ -63,6 +63,7 @@ export class SheetBarControl {const workbook = this._plugin.getContext().getWorkBook();const worksheet = workbook.getSheetBySheetId(value as string);if (worksheet) {+ debugger;worksheet.hideSheet();}break;diff --git a/packages/core/src/Sheets/Domain/Worksheet.ts b/packages/core/src/Sheets/Domain/Worksheet.tsindex f179eaee2d..711c68e21a 100644--- a/packages/core/src/Sheets/Domain/Worksheet.ts+++ b/packages/core/src/Sheets/Domain/Worksheet.ts@@ -993,7 +993,7 @@ export class Worksheet {_commandManager.invoke(command);observer.notifyObservers({ sheet: this });const index = _workbook.getSheetIndex(this);- if (index) {+ if (index != null) {_workbook.activateSheetByIndex(index);}}diff --git a/packages/ui-plugin-sheets/src/Controller/SheetBarUIContruller.ts b/packages/ui-plugin-sheets/src/Controller/SheetBarUIContruller.tsindex f4b30449b8..07a5c6a57f 100644--- a/packages/ui-plugin-sheets/src/Controller/SheetBarUIContruller.ts+++ b/packages/ui-plugin-sheets/src/Controller/SheetBarUIContruller.ts@@ -17,6 +17,7 @@ import {import { SheetUIPlugin, SHEET_UI_PLUGIN_NAME } from '..';import { SheetBar } from '../View/SheetBar';import styles from '../View/SheetBar/index.module.less';+import { SheetBarMenuItem } from '../View/SheetBar/SheetBarMenu';interface CustomComponent {name: string;@@ -48,7 +49,7 @@ export class SheetBarUIController {protected _sheetList: SheetUlProps[];- protected _menuList: SheetUlProps[];+ protected _menuList: SheetBarMenuItem[];constructor(plugin: Plugin) {let that = this;@@ -108,7 +109,6 @@ export class SheetBarUIController {this._sheetBar.ref.current.showMenu(true);that.setUIObserve('onUIChangeObservable', { name: 'unHideSheet', value: this._dataId });},- border: true,},];this._plugin@@ -211,7 +211,7 @@ export class SheetBarUIController {return this._sheetList;}- getMenuList(): SheetUlProps[] {+ getMenuList(): SheetBarMenuItem[] {return this._menuList;}@@ -314,13 +314,15 @@ export class SheetBarUIController {label: sheet.getName(),index: String(index),sheetId: sheet.getSheetId(),- hidden: sheet.isSheetHidden(),+ hide: sheet.isSheetHidden() === 1,selected: sheet.getStatus() === 1,- onClick: (e: MouseEvent) => {- const target = e.currentTarget as HTMLDivElement;- this._dataId = target.dataset.id as string;- sheet.showSheet();- sheet.activate();+ onClick: (e?: MouseEvent) => {+ if (e) {+ const target = e.currentTarget as HTMLDivElement;+ this._dataId = target.dataset.id as string;+ sheet.showSheet();+ sheet.activate();+ }},}));this._sheetList = sheetsdiff --git a/packages/ui-plugin-sheets/src/View/SheetBar/SheetBarMenu.tsx b/packages/ui-plugin-sheets/src/View/SheetBar/SheetBarMenu.tsxindex 076c4f6dae..28fad95ca8 100644--- a/packages/ui-plugin-sheets/src/View/SheetBar/SheetBarMenu.tsx+++ b/packages/ui-plugin-sheets/src/View/SheetBar/SheetBarMenu.tsx@@ -1,7 +1,7 @@import { Component, Icon, joinClassNames } from '@univerjs/base-ui';import styles from './index.module.less';-interface SheetBarMenuItem {+export interface SheetBarMenuItem {label?: string;hide?: boolean;selected?: boolean;@@ -55,10 +55,9 @@ export class SheetBarMenu extends Component<SheetBarMenuProps, IState> {return (<ul className={styles.sheetBarMenu} style={{ ...style, display: show ? 'block' : ' none' }}>{menu.map((item) => (- <li onClick={(e) => this.handleClick(e, item)} className={joinClassNames(styles.sheetBarMenuItem, item.hide ? styles.sheetBarMenuItemHide : '')}>+ <li onClick={(e) => this.handleClick(e, item)} className={joinClassNames(styles.sheetBarMenuItem)}><span className={styles.sheetBarMenuIcon}>- {item.hide ? <Icon.HideIcon /> : ''}- {item.selected ? <Icon.Data.CheckIcon className={styles.sheetBarMenuSvg} /> : ''}+ <EffIcon item={item}></EffIcon></span><span className={styles.sheetBarMenuTitle}>{item.label}</span></li>@@ -67,3 +66,13 @@ export class SheetBarMenu extends Component<SheetBarMenuProps, IState> {);}}++function EffIcon(props: { item: SheetBarMenuItem }) {+ if (props.item.hide) {+ return <Icon.HideIcon />;+ }+ if (props.item.selected) {+ return <Icon.Data.CheckIcon className={styles.sheetBarMenuSvg} />;+ }+ return <></>;+}