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): formula input esc invalid (#1902)

Univer87f0994f914b
diff --git a/packages/sheets-formula/src/controllers/prompt.controller.ts b/packages/sheets-formula/src/controllers/prompt.controller.ts
index 66fc9eeb8e..5afe716c01 100644
--- a/packages/sheets-formula/src/controllers/prompt.controller.ts
+++ b/packages/sheets-formula/src/controllers/prompt.controller.ts
@@ -1772,6 +1772,19 @@ export class PromptController extends Disposable {
return;
}
+ if (keycode === KeyCode.ESC) {
+ const focusEditor = this._editorService.getFocusEditor();
+ if (focusEditor && focusEditor.isSheetEditor() === true) {
+ this._editorBridgeService.changeVisible({
+ visible: false,
+ eventType: DeviceInputEventType.Keyboard,
+ keycode,
+ });
+ this._selectionManagerService.refreshSelection();
+ }
+ return;
+ }
+
if (this._formulaPromptService.isSearching()) {
if (keycode === KeyCode.ARROW_DOWN) {
this._formulaPromptService.navigate({ direction: Direction.DOWN });
diff --git a/packages/sheets-formula/src/controllers/shortcuts/prompt.shortcut.ts b/packages/sheets-formula/src/controllers/shortcuts/prompt.shortcut.ts
index 870c8b9a79..bb0835020f 100644
--- a/packages/sheets-formula/src/controllers/shortcuts/prompt.shortcut.ts
+++ b/packages/sheets-formula/src/controllers/shortcuts/prompt.shortcut.ts
@@ -31,7 +31,7 @@ export const PROMPT_SELECTION_KEYCODE_ARROW_LIST = [
KeyCode.ARROW_RIGHT,
];
-export const PROMPT_SELECTION_KEYCODE_LIST = [...PROMPT_SELECTION_KEYCODE_ARROW_LIST, KeyCode.ENTER, KeyCode.TAB];
+export const PROMPT_SELECTION_KEYCODE_LIST = [...PROMPT_SELECTION_KEYCODE_ARROW_LIST, KeyCode.ENTER, KeyCode.TAB, KeyCode.ESC];
export function promptSelectionShortcutItem() {
const shortcutList: IShortcutItem[] = [];