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
feat(sheet): sheet rename confirm, active next unhidden sheet when delete sheet (#1164)
Dushusirba64795a832d
diff --git a/packages/sheets-ui/src/controllers/active-worksheet/active-worksheet.controller.ts b/packages/sheets-ui/src/controllers/active-worksheet/active-worksheet.controller.tsindex aaaaf5b685..c5e0b625f8 100644--- a/packages/sheets-ui/src/controllers/active-worksheet/active-worksheet.controller.ts+++ b/packages/sheets-ui/src/controllers/active-worksheet/active-worksheet.controller.ts@@ -149,12 +149,9 @@ export class ActiveWorksheetController extends Disposable {const previousIndex = this._previousSheetIndex;const nextIndex = previousIndex >= 1 ? previousIndex - 1 : 0;- const nextSheet = workbook.getSheetByIndex(nextIndex);- if (!nextSheet) {- throw new Error('[ActiveWorksheetController]: cannot find the next sheet!');- }+ const nextId = findTheNextUnhiddenSheet(workbook, nextIndex);- this._switchToNextSheet(unitId, nextSheet.getSheetId());+ this._switchToNextSheet(unitId, nextId);}private _adjustActiveSheetOnInsertSheet(mutation: IMutationInfo<IInsertSheetMutationParams>) {diff --git a/packages/sheets-ui/src/services/selection/selection-render.service.ts b/packages/sheets-ui/src/services/selection/selection-render.service.tsindex 48974dd620..5c2e338eb2 100644--- a/packages/sheets-ui/src/services/selection/selection-render.service.ts+++ b/packages/sheets-ui/src/services/selection/selection-render.service.ts@@ -469,6 +469,10 @@ export class SelectionRenderService implements ISelectionRenderService {endSelection() {this._endSelection();+ this._selectionMoveEnd$.next(this.getSelectionDataWithStyle());++ // when selection mouse up, enable the short cut service+ this._shortcutService.setDisable(false);}reset() {diff --git a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.tsx b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.tsxindex 422bded3f3..63c1fc7898 100644--- a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.tsx+++ b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.tsx@@ -35,6 +35,7 @@ import { useDependency, useInjector } from '@wendellhu/redi/react-bindings';import React, { useEffect, useRef, useState } from 'react';import { SheetMenuPosition } from '../../../controllers/menu/menu';+import { ISelectionRenderService } from '../../../services/selection/selection-render.service';import { ISheetBarService } from '../../../services/sheet-bar/sheet-bar.service';import styles from './index.module.less';import type { IBaseSheetBarProps } from './SheetBarItem';@@ -58,6 +59,7 @@ export function SheetBarTabs() {const sheetBarService = useDependency(ISheetBarService);const localeService = useDependency(LocaleService);const confirmService = useDependency(IConfirmService);+ const selectionRenderService = useDependency(ISelectionRenderService);const injector = useInjector();const workbook = univerInstanceService.getCurrentUniverSheetInstance();@@ -151,12 +153,12 @@ export function SheetBarTabs() {cancelText: localeService.t('button.cancel'),confirmText: localeService.t('button.confirm'),onClose() {- confirmService.close(id);focusTabEditor();+ confirmService.close(id);},onConfirm() {- confirmService.close(id);focusTabEditor();+ confirmService.close(id);},});@@ -184,11 +186,11 @@ export function SheetBarTabs() {confirmText: localeService.t('button.confirm'),onClose() {confirmService.close(id);- setTabEditor();+ focusTabEditor();},onConfirm() {confirmService.close(id);- setTabEditor();+ focusTabEditor();},});}@@ -197,10 +199,16 @@ export function SheetBarTabs() {};const focusTabEditor = () => {- const slideTabEditor = slideTabBarRef.current.slideTabBar?.getActiveItem()?.getEditor();- if (slideTabEditor) {- slideTabEditor.focus();- }+ selectionRenderService.endSelection();++ // There is an asynchronous operation in endSelection, which will trigger blur immediately after focus, so it must be wrapped with setTimeout.+ setTimeout(() => {+ const activeSlideTab = slideTabBarRef.current.slideTabBar?.getActiveItem();+ if (activeSlideTab) {+ activeSlideTab.focus();+ activeSlideTab.selectAll();+ }+ }, 0);};const setTabEditor = () => {diff --git a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/utils/slide-tab-bar.ts b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/utils/slide-tab-bar.tsindex 8f4e6e9d3c..9a78b01d38 100644--- a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/utils/slide-tab-bar.ts+++ b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/utils/slide-tab-bar.ts@@ -94,6 +94,15 @@ export class SlideTabItem {return this._slideTabItem.querySelector('span');}+ focus() {+ this.getEditor()?.focus();+ }++ selectAll() {+ const input = this.getEditor();+ input && SlideTabBar.keepSelectAll(input);+ }+isEditMode(): boolean {return this._editMode;}