Skip to content

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.

fix: refocus sheet cell when create new sheet (#1896)

Ran Luodb884470755c
diff --git a/packages/sheets-ui/src/controllers/editor-bridge.controller.ts b/packages/sheets-ui/src/controllers/editor-bridge.controller.ts
index 6b260b574e..fb762d7a8d 100644
--- a/packages/sheets-ui/src/controllers/editor-bridge.controller.ts
+++ b/packages/sheets-ui/src/controllers/editor-bridge.controller.ts
@@ -85,6 +85,7 @@ export class EditorBridgeController extends RxDisposable {
}
const textSelectionRenderManager = this._injector.get(ITextSelectionRenderManager, Quantity.OPTIONAL);
+
if (!this._layoutService.checkCanvasIsFocused() && textSelectionRenderManager && !textSelectionRenderManager!.hasFocus()) {
return;
}
diff --git a/packages/ui/src/services/layout/layout.service.ts b/packages/ui/src/services/layout/layout.service.ts
index b82a71e00f..3f2a0a1746 100644
--- a/packages/ui/src/services/layout/layout.service.ts
+++ b/packages/ui/src/services/layout/layout.service.ts
@@ -23,7 +23,7 @@ import { IEditorService } from '../editor/editor.service';
type FocusHandlerFn = (unitId: string) => void;
export const FOCUSING_UNIVER = 'FOCUSING_UNIVER';
-const collectionOfCnForFocusableEle = ['univer-app-layout', 'univer-toolbar-btn', 'univer-menu-item', 'univer-button'];
+const collectionOfCnForFocusableEle = ['univer-app-layout', 'univer-toolbar-btn', 'univer-menu-item', 'univer-button', 'univer-sheet-bar-btn'];
export interface ILayoutService {
readonly isFocused: boolean;