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(editor): focusing error (#2264)

Univer0831994c6588
diff --git a/packages/docs-ui/src/controllers/text-selection.controller.ts b/packages/docs-ui/src/controllers/text-selection.controller.ts
index c218b3fc24..e609e22ea4 100644
--- a/packages/docs-ui/src/controllers/text-selection.controller.ts
+++ b/packages/docs-ui/src/controllers/text-selection.controller.ts
@@ -81,6 +81,7 @@ export class TextSelectionController extends Disposable {
}
}
+ // eslint-disable-next-line max-lines-per-function
private _initialMain(unitId: string) {
const docObject = this._getDocObjectById(unitId);
if (docObject == null) {
@@ -133,6 +134,7 @@ export class TextSelectionController extends Disposable {
* The order of occurrence is such that PointerDown comes first.
* Translate the above text into English.
*/
+ this._setEditorFocus(unitId);
setTimeout(() => {
this._setEditorFocus(unitId);
this._textSelectionRenderManager.setCursorManually(offsetX, offsetY);
diff --git a/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts b/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts
index e58dfc94bc..df2588d9e0 100644
--- a/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts
+++ b/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts
@@ -20,8 +20,10 @@ import {
Disposable,
EDITOR_ACTIVATED,
FOCUSING_EDITOR_BUT_HIDDEN,
+ FOCUSING_EDITOR_STANDALONE,
FOCUSING_FORMULA_EDITOR,
FOCUSING_SHEET,
+ FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE,
HorizontalAlign,
ICommandService,
IContextService,
@@ -165,7 +167,7 @@ export class StartEditController extends Disposable {
const { position, documentLayoutObject, scaleX, editorUnitId } = editCellState;
const editorObject = this._getEditorObject();
- if (editorObject == null) {
+ if (editorObject == null || this._contextService.getContextValue(FOCUSING_EDITOR_STANDALONE) === true || this._contextService.getContextValue(FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE) === true) {
return;
}