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(sheets-ui): restore formula bar after canceling edit (#7653)
wpxp1234560bdbebe388c5
diff --git a/packages/sheets-ui/src/controllers/editor/__tests__/editing-render-business.spec.ts b/packages/sheets-ui/src/controllers/editor/__tests__/editing-render-business.spec.tsindex a1bdb45417..a696dcdcab 100644--- a/packages/sheets-ui/src/controllers/editor/__tests__/editing-render-business.spec.ts+++ b/packages/sheets-ui/src/controllers/editor/__tests__/editing-render-business.spec.ts@@ -166,6 +166,7 @@ function createController(initialDataStream = 'new value\r\n', isPercentFormat =getEditorDirty: vi.fn(() => true),isForceKeepVisible: vi.fn(() => false),disableForceKeepVisible: vi.fn(),+ refreshEditCellState: vi.fn(),refreshEditCellPosition: vi.fn(),changeEditorDirty: vi.fn(),};@@ -353,6 +354,19 @@ describe('EditingRenderController business methods', () => {});});+ it('refreshes editor content when Esc cancels editing', async () => {+ const { controller } = createController();++ await controller._handleEditorInvisible({+ visible: false,+ eventType: DeviceInputEventType.Keyboard,+ unitId: 'unit-1',+ keycode: KeyCode.ESC,+ });++ expect(controller._editorBridgeService.refreshEditCellState).toHaveBeenCalledTimes(1);+ });+it('moves the cursor inside the editor and resets editor state on exit', () => {const { controller, formulaBarEditor } = createController();diff --git a/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts b/packages/sheets-ui/src/controllers/editor/editing.render-controller.tsindex c3c4459b73..5cfc04a7e3 100644--- a/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts+++ b/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts@@ -731,6 +731,7 @@ export class EditingRenderController extends Disposable {if (this._editorBridgeService.isForceKeepVisible()) {this._editorBridgeService.disableForceKeepVisible();}+ this._editorBridgeService.refreshEditCellState();this._refreshCurrentSelections(sheetId);return;}